fix: handle non-fast-forward in push_to_gitea gracefully
This commit is contained in:
+11
-10
@@ -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 = []
|
||||
|
||||
Reference in New Issue
Block a user