Merge pull request #3525 from gsd-build/fix/3516-reapply-patches-md-filter-on-line-231-mi
fix(reapply-patches): add gsd-update filter arm to git-enhanced two-way merge (#3516)
This commit is contained in:
5
.changeset/serene-pandas-zip.md
Normal file
5
.changeset/serene-pandas-zip.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
type: Fixed
|
||||
pr: 3516
|
||||
---
|
||||
**`/gsd-update --reapply` no longer treats installer-authored commits as user customizations** — the git-enhanced two-way merge filter in `get-shit-done/workflows/reapply-patches.md` was missing the `gsd-update` arm after the slash-command rename from `/gsd:update` to `/gsd-update`. Commits created by the current update flow no longer fall through; they now match the exclusion filter and are excluded from the diff, preventing spurious merge-conflict prompts. The legacy `gsd:update` arm is preserved for back-compat, and `GSD update` / `gsd-install` exclusions are unchanged. (#3516)
|
||||
@@ -228,7 +228,7 @@ d. **If ALL differences appear to be mechanical drift → still flag as CONFLICT
|
||||
When the config directory is a git repo but the pristine install commit can't be found, use commit history to identify user changes:
|
||||
```bash
|
||||
# Find non-update commits that touched this file
|
||||
git -C "$CONFIG_DIR" log --oneline --no-merges -- "{file_path}" | grep -v "gsd:update\|GSD update\|gsd-install"
|
||||
git -C "$CONFIG_DIR" log --oneline --no-merges -- "{file_path}" | grep -v "gsd:update\|gsd-update\|GSD update\|gsd-install"
|
||||
```
|
||||
Each matching commit represents an intentional user modification. Use the commit messages and diffs to understand what was changed and why.
|
||||
|
||||
|
||||
123
tests/bug-3516-reapply-patches-gsd-update-filter.test.cjs
Normal file
123
tests/bug-3516-reapply-patches-gsd-update-filter.test.cjs
Normal file
@@ -0,0 +1,123 @@
|
||||
// allow-test-rule: source-text-is-the-product
|
||||
// get-shit-done/workflows/reapply-patches.md is the installed runtime workflow —
|
||||
// its text IS the deployed behavioral contract for the --reapply flag.
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Bug #3516: reapply-patches.md git-enhanced two-way merge filter misses
|
||||
* commits authored by the renamed `/gsd-update` flow.
|
||||
*
|
||||
* The `grep -v` alternation on line 231 only included the legacy `gsd:update`
|
||||
* marker. After the slash-command rename `/gsd:update` → `/gsd-update`, commits
|
||||
* authored by the current flow fall through the filter and are misclassified as
|
||||
* user customizations, prompting spurious merge conflicts during `--reapply`.
|
||||
*
|
||||
* Fix: add `gsd-update` arm to the alternation so both the legacy and current
|
||||
* commit-message prefixes are excluded. `GSD update` and `gsd-install`
|
||||
* exclusions are preserved.
|
||||
*
|
||||
* Per the repo's source-text-is-the-product exception: the workflow file's text
|
||||
* IS the deployed behavioral contract. Structural assertion against the parsed
|
||||
* shell command string is the correct test form here.
|
||||
*/
|
||||
|
||||
const { describe, test, before } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const WORKFLOW_PATH = path.join(
|
||||
__dirname,
|
||||
'..',
|
||||
'get-shit-done',
|
||||
'workflows',
|
||||
'reapply-patches.md',
|
||||
);
|
||||
|
||||
/**
|
||||
* Extract the git log filter command from the workflow.
|
||||
*
|
||||
* Looks for the `grep -v "..."` shell snippet inside the Git-enhanced two-way
|
||||
* merge section and returns the alternation string between the quotes.
|
||||
* Returns null if the snippet is absent (signals a structural regression).
|
||||
*/
|
||||
function extractFilterAlternation(content) {
|
||||
// Match the grep -v "..." line in the bash block
|
||||
const match = content.match(/grep\s+-v\s+"([^"]+)"/);
|
||||
if (!match) return null;
|
||||
return match[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the alternation string (pipe-delimited) into individual arms.
|
||||
* Handles escaped pipes produced by shell regex syntax (`\|`).
|
||||
*/
|
||||
function parseAlternationArms(alternation) {
|
||||
// Shell grep alternation uses \| (escaped pipe); split on that
|
||||
return alternation.split(/\\\|/).map((arm) => arm.trim());
|
||||
}
|
||||
|
||||
describe('Bug #3516: git-enhanced two-way merge filter includes gsd-update arm', () => {
|
||||
let content;
|
||||
let alternation;
|
||||
let arms;
|
||||
|
||||
before(() => {
|
||||
content = fs.readFileSync(WORKFLOW_PATH, 'utf8');
|
||||
alternation = extractFilterAlternation(content);
|
||||
arms = alternation ? parseAlternationArms(alternation) : [];
|
||||
});
|
||||
|
||||
test('workflow file exists', () => {
|
||||
assert.ok(
|
||||
fs.existsSync(WORKFLOW_PATH),
|
||||
'get-shit-done/workflows/reapply-patches.md must exist',
|
||||
);
|
||||
});
|
||||
|
||||
test('git-enhanced two-way merge section contains a grep -v filter', () => {
|
||||
assert.ok(
|
||||
alternation !== null,
|
||||
'reapply-patches.md must contain a `grep -v "..."` filter in the git-enhanced two-way merge section',
|
||||
);
|
||||
});
|
||||
|
||||
test('filter excludes legacy gsd:update commits (back-compat)', () => {
|
||||
assert.ok(
|
||||
arms.some((arm) => arm === 'gsd:update'),
|
||||
`filter must include 'gsd:update' arm for back-compat; got arms: ${JSON.stringify(arms)}`,
|
||||
);
|
||||
});
|
||||
|
||||
test('filter excludes renamed gsd-update commits (primary fix)', () => {
|
||||
assert.ok(
|
||||
arms.some((arm) => arm === 'gsd-update'),
|
||||
`filter must include 'gsd-update' arm (renamed flow); got arms: ${JSON.stringify(arms)}`,
|
||||
);
|
||||
});
|
||||
|
||||
test('filter excludes GSD update commits (no regression)', () => {
|
||||
assert.ok(
|
||||
arms.some((arm) => arm === 'GSD update'),
|
||||
`filter must include 'GSD update' arm; got arms: ${JSON.stringify(arms)}`,
|
||||
);
|
||||
});
|
||||
|
||||
test('filter excludes gsd-install commits (no regression)', () => {
|
||||
assert.ok(
|
||||
arms.some((arm) => arm === 'gsd-install'),
|
||||
`filter must include 'gsd-install' arm; got arms: ${JSON.stringify(arms)}`,
|
||||
);
|
||||
});
|
||||
|
||||
test('all four expected exclusion patterns are present in the filter', () => {
|
||||
const required = ['gsd:update', 'gsd-update', 'GSD update', 'gsd-install'];
|
||||
const missing = required.filter((p) => !arms.some((arm) => arm === p));
|
||||
assert.deepEqual(
|
||||
missing,
|
||||
[],
|
||||
`filter is missing required exclusion patterns: ${JSON.stringify(missing)}; got arms: ${JSON.stringify(arms)}`,
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user