Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(helper): brain-commit-push.sh names skipped paths when its push fails too (GST-2116)
garrytan0f8a59580465
diff --git a/src/core/brain-repo-durability.ts b/src/core/brain-repo-durability.tsindex c6cdc0d589..70f676c071 100644--- a/src/core/brain-repo-durability.ts+++ b/src/core/brain-repo-durability.ts@@ -313,15 +313,19 @@ _unstaged() {return 0}_skipped=""-_finish() {- [ -z "$_skipped" ] && exit 0+_report_skipped() {+ [ -n "$_skipped" ] || return 0{- echo "Error [commit_paths_skipped]: git did not commit these named path(s); the other named paths were committed and pushed:"+ echo "Error [commit_paths_skipped]: git did not commit these named path(s); the other named paths were $1:"printf '%s\\n' "$_skipped" | sed 's/^/ /'echo "Why: git add stages nothing and still exits 0 for a modified file flagged assume-unchanged or skip-worktree, or a file inside a nested Git repository."echo "Fix: read the flags with git ls-files -v -- <path> and ask the user (a skip-worktree flag is often set on purpose to keep local edits out of commits); to commit the edits clear them (git update-index --no-assume-unchanged -- <path>, and separately git update-index --no-skip-worktree -- <path>), or move the file out of the nested repository, then rerun."echo "Next: ask_user"} >&2+}+_finish() {+ [ -z "$_skipped" ] && exit 0+ _report_skipped "committed and pushed"exit 1}echo "[brain-commit-push] gbrain git commit-push unavailable; using the minimal locked commit + push" >&2@@ -361,13 +365,14 @@ exec 9>&- 8>&-unset BRAIN_COMMIT_LOCK_HELD GBRAIN_COMMIT_VIAif command -v flock >/dev/null 2>&1; thenexec 7>"$_gd/brain-publish.lock"- flock -w "\${GBRAIN_PUBLISH_LOCK_WAIT_SECONDS:-300}" 7 || { echo "PUSH FAILED: another push held this checkout's publish lock; the commit is local-only. Run: gbrain git commit-push --push-only" >&2; exit 4; }+ flock -w "\${GBRAIN_PUBLISH_LOCK_WAIT_SECONDS:-300}" 7 || { echo "PUSH FAILED: another push held this checkout's publish lock; the commit is local-only. Run: gbrain git commit-push --push-only" >&2; _report_skipped "committed locally, not pushed"; exit 4; }fiif git push origin "$_head:refs/heads/$_branch" >>"$_log" 2>&1; thenecho "$(date -u +%FT%TZ) [push] ok $_branch $(git rev-parse --short "$_head")" >>"$_log"; _finishfiecho "$(date -u +%FT%TZ) [push] LOCAL-ONLY, NEEDS ATTENTION: $_branch @ $(git rev-parse --short "$_head") push rejected; run gbrain git commit-push --push-only" >>"$_log"echo "PUSH FAILED — the commit is local-only. Install gbrain, then run: gbrain git commit-push --push-only (it merges remote commits safely). Never git pull --rebase here." >&2+_report_skipped "committed locally, not pushed"exit 4`;}diff --git a/test/git-commit-push-skipped-paths-gst2116.test.ts b/test/git-commit-push-skipped-paths-gst2116.test.tsindex 1103655315..163c907e93 100644--- a/test/git-commit-push-skipped-paths-gst2116.test.ts+++ b/test/git-commit-push-skipped-paths-gst2116.test.ts@@ -306,3 +306,16 @@ test('classic: a skipped path still fails commit_paths_skipped when the push faiexpect(headBlob(f, 'people/bob-example.md')).toContain('Second version.');expect(readFileSync(join(f.home, '.gbrain', 'brain-push.log'), 'utf8')).toContain('LOCAL-ONLY, NEEDS ATTENTION: main');}, 60_000);++test('helper without gbrain: a skipped path is still named when the push fails', () => {+ const f = fixture('helper-pushfail', 'classic');+ writeFileSync(join(f.brain, 'people', 'bob-example.md'), page('Bob', 'Second version.'));+ const nested = nestedPage(f, 'carol-example.md');+ git(f.brain, 'remote', 'set-url', 'origin', join(dir, 'missing.git'));+ const r = helper(f, false, 'write pages', 'people/bob-example.md', nested);+ expect(r.status).toBe(4);+ expect(r.stderr).toContain('PUSH FAILED');+ expect(r.stderr).toContain('commit_paths_skipped');+ expect(r.stderr).toContain(nested);+ expect(headBlob(f, 'people/bob-example.md')).toContain('Second version.');+}, 60_000);