Change logic for processing git changes
This commit is contained in:
parent
8d1ecc030d
commit
54aa0a0fad
1 changed files with 7 additions and 8 deletions
|
@ -57,18 +57,17 @@ def get_all_commands(module: ModuleType = jarvis.cogs) -> Dict[str, Callable]:
|
|||
return {k: v for k, v in commands.items() if v}
|
||||
|
||||
|
||||
def get_git_changes() -> dict:
|
||||
def get_git_changes(repo: git.Repo) -> dict:
|
||||
"""Get all Git changes"""
|
||||
repo = git.Repo(".")
|
||||
current_hash = repo.head.object.hexsha
|
||||
origin = repo.remotes.origin
|
||||
changes = origin.fetch()
|
||||
head = repo.head
|
||||
current_hash = head.object.hexsha
|
||||
tracking = head.tracking_branch()
|
||||
|
||||
file_changes = {}
|
||||
for change in changes:
|
||||
if change.commit.hexsha == current_hash:
|
||||
for commit in tracking.commit.iter_items(repo, f"{head.path}..{tracking.path}"):
|
||||
if commit.hexsha == current_hash:
|
||||
break
|
||||
files = change.commit.stats.files
|
||||
files = commit.stats.files
|
||||
for file, stats in files.items():
|
||||
if file not in file_changes:
|
||||
file_changes[file] = {"insertions": 0, "deletions": 0, "lines": 0}
|
||||
|
|
Loading…
Add table
Reference in a new issue