Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(git): a write-through fails commit_paths_skipped only for its own skipped paths, not for a flagged file left in the ledger (GST-2118)
garrytan7768abed1e7f
diff --git a/src/core/git/commit-push.ts b/src/core/git/commit-push.tsindex c237b38bfb..61829b5dce 100644--- a/src/core/git/commit-push.ts+++ b/src/core/git/commit-push.ts@@ -755,12 +755,12 @@ export function commitPathsLocked(repo: string, rel: string[], message: string,commit = commitPaths(root, paths, message, scope);}// GST-2118: a file git left out stays in the ledger, so doctor dirty_age reports it and --pending retries it loudly.- const skipped = commit.skipped.map(s => s.path).filter(p => paths.includes(p));- if (skipped.length) notePending(root, skipped);+ const ownSkipped = commit.skipped.filter(s => paths.includes(s.path));+ if (ownSkipped.length) notePending(root, ownSkipped.map(s => s.path));settlePending(root);- if (commit.skipped.length) {+ if (ownSkipped.length) {const branch = git(root, ['symbolic-ref', '--quiet', '--short', 'HEAD']).stdout.trim();- throw skippedPathsError(root, commit.skipped, { outcome: commit.sha ? 'committed_local' : 'nothing_to_commit', sha: commit.sha, committed: commit.sha, branch, remote: '', paths, integrated: 0, checkout: 'unchanged' });+ throw skippedPathsError(root, ownSkipped, { outcome: commit.sha ? 'committed_local' : 'nothing_to_commit', sha: commit.sha, committed: commit.sha, branch, remote: '', paths, integrated: 0, checkout: 'unchanged' });}return commit.sha;} catch (e) {diff --git a/test/pending-ledger-flagged-gst2118.test.ts b/test/pending-ledger-flagged-gst2118.test.tsindex f9175b9eea..f2359d2d42 100644--- a/test/pending-ledger-flagged-gst2118.test.ts+++ b/test/pending-ledger-flagged-gst2118.test.ts@@ -147,6 +147,18 @@ test('page write-through end to end: a flagged page is reported not committed, nexpect(ledger(brain)).toEqual([]);});+test('a skip-worktree file left in the ledger does not fail a later write-through of another page', async () => {+ const brain = fixture('skip-later');+ git(brain, 'update-index', '--skip-worktree', '--', 'people/alice-example.md');+ writeFileSync(join(brain, 'people', 'alice-example.md'), page('Hidden', 'A write-through edit git add refuses.'));+ notePending(brain, ['people/alice-example.md']);+ writeFileSync(join(brain, 'people', 'bob-example.md'), page('Bob', 'Second version.'));+ const sha = await withEnv(identity, async () => commitPathsLocked(brain, [join(brain, 'people', 'bob-example.md')], 'w', { lockWaitMs: 1000 }));+ expect(sha).toBe(git(brain, 'rev-parse', 'HEAD').trim());+ expect(headBlob(brain, 'people/bob-example.md')).toContain('Second version.');+ expect(ledger(brain)).toEqual(['people/alice-example.md']);+});+test('control: an ordinary pending file is committed by --pending and the ledger settles empty', async () => {const brain = fixture('pending-ok', true);writeFileSync(join(brain, 'people', 'alice-example.md'), page('Alice', 'Second version.'));