Skip to content

fix: tell a failed push apart from a pull request behind its base - #16

Merged
Mearman merged 1 commit into
mainfrom
fix/push-failure-misread
Nov 26, 2026
Merged

Mearman merged 1 commit into
mainfrom
fix/push-failure-misread

Conversation

@Mearman

@Mearman Mearman commented Nov 26, 2026

Copy link
Copy Markdown
Member

A fast-forward merge treated every failed push to the base as the pull request being behind it. When the SSH connection was dropped (Connection closed by <ip> port 22, fatal: Could not read from remote repository), the run either said the branch needed updating or, with update-behind: true, rebased a branch that already contained the base, printed was behind; rebased it, and CI will run on the new head and exited 0. The pull request was never merged and nothing said so.

  • After a failed push the base is fetched again, and git merge-base --is-ancestor decides. Only a base that is not contained in the head counts as behind; otherwise the run fails with git's error, or reports that the head is already on the base if the push did land.
  • then: rebase leaves alone a head that already contains its base, so it cannot report a rebase that changed nothing, with or without a behind condition. The other head-branch pushes already stop the run when they fail.
  • Every fetch and push goes through one helper that tries a connection failure up to three times. A refusal is not retried.

test/transport.bats covers these. Against the previous script it fails apart from the head-branch push that keeps failing, including the false rebased it report; with the change it passes.

To reproduce with the stubs: PUSH_ERROR="git@github.com: Permission denied (publickey)." PUSH_ERROR_TIMES=1 UPDATE_BEHIND=true on a fast-forward run.

A fast-forward merge read every failed push to the base as the pull request
being behind it. A dropped connection then either left the run saying the branch
needed updating, or, with update-behind, rebased a branch that already held the
base, reported that it had rebased it and exited successfully, so the pull
request was never merged and nothing said so.

After a rejected push the base is fetched again, and the pull request counts as
behind only when the base is not an ancestor of its head.
Any other failed push fails the run with git's error.

The rebase effect likewise leaves alone a head that already contains its base,
whatever the conditions say, since rebasing it changes nothing.

Every fetch and push is tried again a bounded number of times when its
connection fails.
@Mearman Mearman added the automerge Merge once Required Checks pass label Nov 26, 2026
@Mearman
Mearman merged commit c3aa167 into main Nov 26, 2026
10 checks passed
@Mearman
Mearman deleted the fix/push-failure-misread branch November 26, 2026 09:43
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.5.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Merge once Required Checks pass released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant