fix: handle non-fast-forward in push_to_gitea gracefully

This commit is contained in:
2026-06-24 15:38:35 +02:00
parent 24132b737e
commit 7f3fe388ad
+11 -10
View File
@@ -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 = []