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}
|
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"""
|
"""Get all Git changes"""
|
||||||
repo = git.Repo(".")
|
head = repo.head
|
||||||
current_hash = repo.head.object.hexsha
|
current_hash = head.object.hexsha
|
||||||
origin = repo.remotes.origin
|
tracking = head.tracking_branch()
|
||||||
changes = origin.fetch()
|
|
||||||
|
|
||||||
file_changes = {}
|
file_changes = {}
|
||||||
for change in changes:
|
for commit in tracking.commit.iter_items(repo, f"{head.path}..{tracking.path}"):
|
||||||
if change.commit.hexsha == current_hash:
|
if commit.hexsha == current_hash:
|
||||||
break
|
break
|
||||||
files = change.commit.stats.files
|
files = commit.stats.files
|
||||||
for file, stats in files.items():
|
for file, stats in files.items():
|
||||||
if file not in file_changes:
|
if file not in file_changes:
|
||||||
file_changes[file] = {"insertions": 0, "deletions": 0, "lines": 0}
|
file_changes[file] = {"insertions": 0, "deletions": 0, "lines": 0}
|
||||||
|
|
Loading…
Add table
Reference in a new issue