fix(git-gate): forward force push as +refspec to upstream #234

Merged
didericis merged 1 commits from fix/gate-force-push into main 2026-06-10 22:24:38 -04:00
Collaborator

Closes #233.

Summary

When a client does git push --force, the gate's pre-receive hook was always building the forwarded refspec as $new:$ref. The upstream rejected this as a non-fast-forward because the + force prefix was missing.

Fix: detect force pushes via git merge-base --is-ancestor $old $new when $old != $zero. If the old tip is not an ancestor of the new tip, forward +$new:$ref.

Changed file: bot_bottle/git_gate.py

Closes #233. ## Summary When a client does `git push --force`, the gate's pre-receive hook was always building the forwarded refspec as `$new:$ref`. The upstream rejected this as a non-fast-forward because the `+` force prefix was missing. Fix: detect force pushes via `git merge-base --is-ancestor $old $new` when `$old != $zero`. If the old tip is not an ancestor of the new tip, forward `+$new:$ref`. Changed file: [bot_bottle/git_gate.py](https://gitea.dideric.is/didericis/bot-bottle/src/commit/b00b0ba4aa5088988627e5be398596debc4f651c/bot_bottle/git_gate.py)
didericis-claude added 1 commit 2026-06-10 22:17:55 -04:00
fix(git-gate): forward force push as +refspec to upstream
test / unit (pull_request) Successful in 38s
test / integration (pull_request) Successful in 22s
lint / lint (push) Successful in 1m47s
test / unit (push) Successful in 34s
test / integration (push) Successful in 20s
Update Quality Badges / update-badges (push) Successful in 1m21s
b00b0ba4aa
When $old != zero and $new is not a descendant of $old (detected via
git merge-base --is-ancestor), the hook now forwards +$new:$ref so the
upstream accepts the force push instead of rejecting it as a
non-fast-forward.

Closes #233
didericis approved these changes 2026-06-10 22:24:31 -04:00
didericis merged commit b00b0ba4aa into main 2026-06-10 22:24:38 -04:00
didericis deleted branch fix/gate-force-push 2026-06-10 22:24:38 -04:00
Sign in to join this conversation.