fix: respect git add option terminator
This commit is contained in:
@@ -46,6 +46,7 @@ function forceGitAddCwds(command, defaultCwd) {
|
|||||||
|
|
||||||
if (tokens[j] !== 'add') continue;
|
if (tokens[j] !== 'add') continue;
|
||||||
for (let k = j + 1; k < tokens.length && !separators.has(tokens[k]); k++) {
|
for (let k = j + 1; k < tokens.length && !separators.has(tokens[k]); k++) {
|
||||||
|
if (tokens[k] === '--') break;
|
||||||
if (tokens[k] === '--force' || tokens[k] === '-f' || /^-[A-Za-z]*f[A-Za-z]*$/.test(tokens[k])) {
|
if (tokens[k] === '--force' || tokens[k] === '-f' || /^-[A-Za-z]*f[A-Za-z]*$/.test(tokens[k])) {
|
||||||
cwdList.push(gitCwd);
|
cwdList.push(gitCwd);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -89,6 +89,18 @@ describe('bug #261: workflow guard blocks forced git add on worktree-agent branc
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('allows pathspecs named like force flags after git add -- terminator', () => {
|
||||||
|
const dir = makeRepo('worktree-agent-d4');
|
||||||
|
try {
|
||||||
|
setWorkflowGuard(dir, true);
|
||||||
|
const result = runBashHook(dir, 'git add -- -f');
|
||||||
|
assert.strictEqual(result.status, 0);
|
||||||
|
assert.strictEqual(result.stdout, '');
|
||||||
|
} finally {
|
||||||
|
fs.rmSync(dir, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test('allows git add -f outside worktree-agent branches', () => {
|
test('allows git add -f outside worktree-agent branches', () => {
|
||||||
const dir = makeRepo('feature-docs');
|
const dir = makeRepo('feature-docs');
|
||||||
try {
|
try {
|
||||||
@@ -102,7 +114,7 @@ describe('bug #261: workflow guard blocks forced git add on worktree-agent branc
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('allows git add -f on worktree-agent branch when workflow guard is disabled', () => {
|
test('allows git add -f on worktree-agent branch when workflow guard is disabled', () => {
|
||||||
const dir = makeRepo('worktree-agent-d4');
|
const dir = makeRepo('worktree-agent-e5');
|
||||||
try {
|
try {
|
||||||
setWorkflowGuard(dir, false);
|
setWorkflowGuard(dir, false);
|
||||||
const result = runBashHook(dir, 'git add -f .planning/SUMMARY.md');
|
const result = runBashHook(dir, 'git add -f .planning/SUMMARY.md');
|
||||||
@@ -114,7 +126,7 @@ describe('bug #261: workflow guard blocks forced git add on worktree-agent branc
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('allows git add -f on worktree-agent branch when no GSD config exists', () => {
|
test('allows git add -f on worktree-agent branch when no GSD config exists', () => {
|
||||||
const dir = makeRepo('worktree-agent-e5');
|
const dir = makeRepo('worktree-agent-f6');
|
||||||
try {
|
try {
|
||||||
const result = runBashHook(dir, 'git add -f .planning/SUMMARY.md');
|
const result = runBashHook(dir, 'git add -f .planning/SUMMARY.md');
|
||||||
assert.strictEqual(result.status, 0);
|
assert.strictEqual(result.status, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user