From b4ac46f925f9757aabfad90d7b01ec5ff87fa365 Mon Sep 17 00:00:00 2001 From: Sebastian Mark Date: Thu, 21 Dec 2023 18:38:28 +0100 Subject: [PATCH] refactor: optimize git fetch process MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - replace direct git fetch call with origin.fetch method for better error handling - use fetch result to check for new commits instead of comparing HEAD with active branch 🤖 --- lib/helper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/helper.py b/lib/helper.py index 80caf03..bb9138d 100644 --- a/lib/helper.py +++ b/lib/helper.py @@ -59,13 +59,13 @@ def update_git_repo(repo_path: str, ignore_git_status: bool) -> bool: if not ignore_git_status: # try to fetch latest changes try: - repo.git.fetch() + fetch_res = repo.remotes.origin.fetch()[0] except git.exc.GitCommandError as e: log.error(str(e)) return False # check for new commits - if repo.rev_parse("HEAD") == repo.rev_parse(f"origin/{repo.active_branch}"): + if not fetch_res.old_commit: log.info("no changes - skipping") return False