Skip to content

Fix sweep aborting before push when origin/HEAD is unset - #62

Merged
goldingn merged 2 commits into
mainfrom
fix-sweep-push-abort
Jul 24, 2026
Merged

Fix sweep aborting before push when origin/HEAD is unset#62
goldingn merged 2 commits into
mainfrom
fix-sweep-push-abort

Conversation

@goldingn

Copy link
Copy Markdown
Contributor

🤖 Posted by Claude (Opus 4.8), an AI coding agent, from the @goldingn account — not written by a human. Why.

Fixes #61. Follow-up bug fix to #60.

Symptom. The first real use of the new policy — sweeping the main session-log strand — committed the log but left main ahead 1, unpushed. I completed that push by hand (it's a log-only commit, so the policy allows it); this fixes the sweep so it doesn't recur.

Cause. The default-branch probe git symbolic-ref refs/remotes/origin/HEAD fails when origin/HEAD isn't configured locally (the common case, this repo included). Under set -e + pipefail that abort landed after the commit but before the push. It slipped through because the pre-merge manual check had run git remote set-head, which sets origin/HEAD — so the check passed on a repo state the real one didn't share.

Fix.

  • sweep-session-logs.sh: make the probe non-fatal (|| true), fall back to main.
  • test-sweep-session-logs.sh (new): drives the sweep against a bare remote with origin/HEAD deliberately unset — asserts commit-and-push on the default branch, commit-without-push on a feature branch, and a clean no-op. This is the test that would have caught it.
  • hooks-test.yaml: runs the new test in CI next to the hook test.

8/8 pass locally.

How this was produced

sweep-session-logs.sh probes the default branch with `git symbolic-ref
refs/remotes/origin/HEAD`, which fails when origin/HEAD is not configured
locally (the common case). Under `set -e` + pipefail the failure aborted
the script after the log commit but before the push, so the sweep on
`main` committed without pushing. Make the probe non-fatal and fall back
to `main`.

Regression test: test-sweep-session-logs.sh drives the sweep against a bare
remote with origin/HEAD deliberately unset, asserting it commits and pushes
on the default branch, commits without pushing on a feature branch, and
no-ops cleanly. Wired into hooks-test.yaml. 8/8 pass; would have caught
this (the pre-merge manual check passed only because it had set origin/HEAD).

Fixes #61

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R8QmvZEJTz9b7uNfJZTy3n

@goldingn goldingn left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, fine.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R8QmvZEJTz9b7uNfJZTy3n
@goldingn
goldingn marked this pull request as ready for review July 24, 2026 05:56
@goldingn
goldingn merged commit ea61a7a into main Jul 24, 2026
@goldingn
goldingn deleted the fix-sweep-push-abort branch July 24, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sweep-session-logs.sh aborts before pushing when origin/HEAD is unset

1 participant