From 7f3fe388ad08954c1f121bf978ab9a9ea3ab8b19 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnier Date: Wed, 24 Jun 2026 15:38:35 +0200 Subject: [PATCH] fix: handle non-fast-forward in push_to_gitea gracefully --- svn_mirror/gitea.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/svn_mirror/gitea.py b/svn_mirror/gitea.py index b13b494..172e6cc 100644 --- a/svn_mirror/gitea.py +++ b/svn_mirror/gitea.py @@ -82,16 +82,17 @@ def push_to_gitea(mirror: Mirror) -> bool: # Gitea fetches from canonical — this transfers objects + refs, # and DOES NOT trigger Gitea's pre-receive hook. - # NOTE: no `+` prefix on heads — only fast-forward allowed. - # If Gitea is ahead (user pushed there), this fetch is a no-op - # and `fetch_from_gitea` brings those commits into canonical next. - _git( - "--git-dir", str(gitea_path), "fetch", "--prune", - canonical, - "refs/heads/*:refs/heads/*", - "+refs/tags/*:refs/tags/*", - timeout=300, - ) + # Only fast-forward updates allowed (no `+` prefix on heads). + # If Gitea is ahead (user pushed there), this is safely skipped. + cmd = ["git", "--git-dir", str(gitea_path), "fetch", "--prune", + canonical, "refs/heads/*:refs/heads/*", + "+refs/tags/*:refs/tags/*"] + try: + subprocess.run(cmd, capture_output=True, timeout=300, + env={**os.environ, "LC_ALL": "C"}, + check=True) + except subprocess.CalledProcessError: + logger.debug("Gitea ahead of canonical (non-fast-forward) – fetch skipped") # Build the changelist for post-receive changed: list = []