Fix sweep aborting before push when origin/HEAD is unset - #62
Merged
Conversation
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
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R8QmvZEJTz9b7uNfJZTy3n
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #61. Follow-up bug fix to #60.
Symptom. The first real use of the new policy — sweeping the
mainsession-log strand — committed the log but leftmainahead 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/HEADfails whenorigin/HEADisn't configured locally (the common case, this repo included). Underset -e+pipefailthat abort landed after the commit but before the push. It slipped through because the pre-merge manual check had rungit remote set-head, which setsorigin/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 tomain.test-sweep-session-logs.sh(new): drives the sweep against a bare remote withorigin/HEADdeliberately 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
origin/HEADunset), so a futureset_head-in-test can't hide it again.