diff --git a/jarvis/utils/updates.py b/jarvis/utils/updates.py index 65f597c..8016b7d 100644 --- a/jarvis/utils/updates.py +++ b/jarvis/utils/updates.py @@ -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}