Skip to content

fix(claude-config-backup): rebase on rejected push and log the push error - #17

Merged
twistedmelonman merged 1 commit into
mainfrom
claude/fix-config-backup-push-rebase-059cfb3e
Oct 28, 2026
Merged

twistedmelonman merged 1 commit into
mainfrom
claude/fix-config-backup-push-rebase-059cfb3e

Conversation

@twistedmelonman

Copy link
Copy Markdown
Member

The backup push sent stderr to /dev/null. After a commit was added to the remote from elsewhere on 2026-09-08, every push from ASIAGO was rejected non-fast-forward for seven weeks. The log said only "push failed", and the clone ended 1026 commits ahead. That was fixed by hand on 2026-10-28; this keeps it from recurring.

  • Push stderr is kept; the WARN line shows git's first !/error:/fatal: line, with URL userinfo stripped.
  • A rejection with (fetch first) or (non-fast-forward) runs git pull --rebase on the current branch and pushes once more.
  • A rebase conflict is aborted and logged as ERROR with the conflicting file and the manual fix; the script exits 1 and keeps local commits. Nothing force-pushes or resets.
  • A run with nothing new to commit still pushes when HEAD is ahead of origin/<branch> (local ref check, no fetch). Before, a failed push waited for the next config change.
  • GIT_TERMINAL_PROMPT=0 on push and pull, since this runs under a LaunchAgent.

Tests: new tests/claude-config-backup.bats (7 cases) runs the script against a temp HOME and XDG_DATA_HOME, a bare origin and stubbed gitleaks/stat. Against the old script, 4 of the first 5 fail. shellcheck -S info clean.

…rror

The push sent stderr to /dev/null. After a commit landed on the remote
from elsewhere on 2026-09-08, every push was rejected non-fast-forward
for seven weeks, and the log said only "push failed" each time.

- Keep push stderr and put its first !/error:/fatal: line in the WARN
  line, with any URL userinfo stripped.
- When the push is rejected with "(fetch first)" or
  "(non-fast-forward)", run `git pull --rebase` on the current branch
  and push once more.
- If that rebase conflicts, abort it, log an ERROR naming the
  conflicting file and the manual fix, and exit 1. Local commits are
  left intact; nothing force-pushes or resets.
- Retry the push on a run with nothing new to commit when HEAD is ahead
  of origin/<branch> (local ref check, no fetch). Before, a failed push
  waited until a config file changed again.
- Set GIT_TERMINAL_PROMPT=0 on the network calls, since this runs
  unattended under a LaunchAgent.

Adds tests/claude-config-backup.bats, which runs the script against a
temp HOME, XDG_DATA_HOME, bare origin, and stubbed gitleaks and stat.
@twistedmelonman
twistedmelonman merged commit d1e1cf1 into main Oct 28, 2026
6 checks passed
@twistedmelonman
twistedmelonman deleted the claude/fix-config-backup-push-rebase-059cfb3e branch October 28, 2026 18:32
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.

1 participant