From 973ed5b076a8bd1ad3f888bf3d37d9eab70d267b Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Sun, 25 Oct 2026 19:16:35 +0100 Subject: [PATCH] tree: push: also retry 10 times Recently, the brancher service didn't manage to push a new branch, likely because GitHub had some transient issues. The error message was unclear: remote: fatal error in commit_refs Simply retry, similar to what is done with the 'fetch' part. While at it, avoid an extra unneeded sleep at the end before the raise. Signed-off-by: Matthieu Baerts --- core/tree.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/core/tree.py b/core/tree.py index 481e3b90..fa8f6f2b 100644 --- a/core/tree.py +++ b/core/tree.py @@ -84,6 +84,17 @@ def git(self, args: List[str]): finally: self.lock.release() + def git_retry(self, cmd, err_msg, n=10, sleep=30): + last = n - 1 + for i in range(n): + try: + return self.git(cmd) + except CMD.CmdError as e: + core.log(f"{err_msg} (attempt {i + 1})", repr(e)) + if i == last: + raise + time.sleep(sleep) + def git_am(self, patch): return self.git(["am", "-s", "--", patch]) @@ -101,7 +112,7 @@ def git_pull(self, pull_url, ff=None): def git_push(self, remote, spec): cmd = ["push", remote, spec] - return self.git(cmd) + return self.git_retry(cmd, "Pushing failed") def git_status(self, untracked=None, short=False): cmd = ["status"] @@ -118,14 +129,7 @@ def git_merge_base(self, c1, c2, is_ancestor=False): return self.git(cmd) def git_fetch(self, remote): - for i in range(10): - try: - return self.git(['fetch', remote]) - except CMD.CmdError as e: - core.log(f"Fetching failed (attempt {i + 1})", repr(e)) - time.sleep(30) - if i >= 9: - raise + return self.git_retry(['fetch', remote], "Fetching failed") def git_reset(self, target, hard=False): cmd = ['reset', target]