refactor: optimize git fetch process
- 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
🤖
This commit is contained in:
parent
130b26ba5f
commit
b4ac46f925
1 changed files with 2 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue