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,
|
# Gitea fetches from canonical — this transfers objects + refs,
|
||||||
# and DOES NOT trigger Gitea's pre-receive hook.
|
# and DOES NOT trigger Gitea's pre-receive hook.
|
||||||
# NOTE: no `+` prefix on heads — only fast-forward allowed.
|
# Only fast-forward updates allowed (no `+` prefix on heads).
|
||||||
# If Gitea is ahead (user pushed there), this fetch is a no-op
|
# If Gitea is ahead (user pushed there), this is safely skipped.
|
||||||
# and `fetch_from_gitea` brings those commits into canonical next.
|
cmd = ["git", "--git-dir", str(gitea_path), "fetch", "--prune",
|
||||||
_git(
|
canonical, "refs/heads/*:refs/heads/*",
|
||||||
"--git-dir", str(gitea_path), "fetch", "--prune",
|
"+refs/tags/*:refs/tags/*"]
|
||||||
canonical,
|
try:
|
||||||
"refs/heads/*:refs/heads/*",
|
subprocess.run(cmd, capture_output=True, timeout=300,
|
||||||
"+refs/tags/*:refs/tags/*",
|
env={**os.environ, "LC_ALL": "C"},
|
||||||
timeout=300,
|
check=True)
|
||||||
)
|
except subprocess.CalledProcessError:
|
||||||
|
logger.debug("Gitea ahead of canonical (non-fast-forward) – fetch skipped")
|
||||||
|
|
||||||
# Build the changelist for post-receive
|
# Build the changelist for post-receive
|
||||||
changed: list = []
|
changed: list = []
|
||||||
|
|||||||
Reference in New Issue
Block a user