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

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
This commit was merged in pull request #234.
This commit is contained in:
2026-06-11 02:17:27 +00:00
parent 3f04567290
commit b00b0ba4aa
2 changed files with 9 additions and 0 deletions
+7
View File
@@ -181,6 +181,13 @@ class TestHookRender(unittest.TestCase):
self.assertIn("BatchMode=yes", hook)
self.assertIn("ConnectTimeout=", hook)
def test_force_push_uses_plus_refspec(self):
# A non-fast-forward push (old != zero, new not a descendant of old)
# must forward +$new:$ref so the upstream accepts the force push.
hook = git_gate_render_hook()
self.assertIn('git merge-base --is-ancestor "$old" "$new"', hook)
self.assertIn('refspec="+$new:$ref"', hook)
def test_forward_preserves_push_options(self):
# Git exposes push options to pre-receive hooks as
# GIT_PUSH_OPTION_COUNT + indexed GIT_PUSH_OPTION_N variables.