mirror of
https://github.com/glittercowboy/get-shit-done
synced 2026-04-25 17:25:23 +02:00
- quick.md Step 5.6: commit PLAN.md to base branch before worktree executor spawn when USE_WORKTREES is active, preventing CC #36182 path-resolution drift that caused silent writes to main repo instead of worktree - reapply-patches.md Option A: replace first-add commit heuristic with pristine_hashes SHA-256 matching from backup-meta.json so baseline detection works correctly on multi-cycle repos; first-add fallback kept for older installers without pristine_hashes - CONFIGURATION.md: move security_enforcement/security_asvs_level/security_block_on to workflow.* (matches templates/config.json and workflow readers); rename context_profile → context (matches VALID_CONFIG_KEYS in config.cjs); add planning.sub_repos to schema example - universal-anti-patterns.md + context-budget.md: fix context_window_tokens → context_window (the actual key name in config.cjs) Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
81 lines
3.6 KiB
JavaScript
81 lines
3.6 KiB
JavaScript
/**
|
|
* Bug #2424: reapply-patches pristine-baseline detection uses first-add commit
|
|
*
|
|
* The three-way merge baseline detection previously used `git log --diff-filter=A`
|
|
* which returns the commit that FIRST added the file. On repos that have been
|
|
* through multiple GSD update cycles, this returns a stale, many-versions-old
|
|
* baseline — not the version immediately prior to the current update.
|
|
*
|
|
* Fix: Option A must prefer `pristine_hashes` from backup-meta.json to locate
|
|
* the correct baseline commit by SHA-256 matching, with a fallback to the
|
|
* first-add heuristic only when no pristine hash is recorded.
|
|
*/
|
|
|
|
const { describe, test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const REAPPLY_MD = path.join(__dirname, '..', 'commands', 'gsd', 'reapply-patches.md');
|
|
|
|
describe('reapply-patches pristine baseline detection (#2424)', () => {
|
|
let content;
|
|
|
|
test('reapply-patches.md exists', () => {
|
|
assert.ok(fs.existsSync(REAPPLY_MD), 'commands/gsd/reapply-patches.md must exist');
|
|
content = fs.readFileSync(REAPPLY_MD, 'utf-8');
|
|
});
|
|
|
|
test('Option A references pristine_hashes from backup-meta.json', () => {
|
|
const optionAStart = content.indexOf('### Option A');
|
|
const optionBStart = content.indexOf('### Option B');
|
|
assert.ok(optionAStart !== -1, 'Option A section must exist');
|
|
assert.ok(optionBStart !== -1, 'Option B section must exist');
|
|
const optionABlock = content.slice(optionAStart, optionBStart);
|
|
assert.ok(
|
|
optionABlock.includes('pristine_hashes'),
|
|
'Option A must use pristine_hashes from backup-meta.json as the primary baseline source'
|
|
);
|
|
assert.ok(
|
|
optionABlock.includes('backup-meta.json'),
|
|
'Option A must explicitly read backup-meta.json for the pristine hash'
|
|
);
|
|
});
|
|
|
|
test('Option A iterates commit history to find hash-matching commit', () => {
|
|
const optionAStart = content.indexOf('### Option A');
|
|
const optionBStart = content.indexOf('### Option B');
|
|
const optionABlock = content.slice(optionAStart, optionBStart);
|
|
// Must walk commits and compare hashes — not just take the first-add commit
|
|
assert.ok(
|
|
optionABlock.includes('sha256') || optionABlock.includes('SHA-256') || optionABlock.includes('sha256sum'),
|
|
'Option A must compare SHA-256 hashes to identify the correct baseline commit'
|
|
);
|
|
assert.ok(
|
|
optionABlock.includes('git log') && optionABlock.includes('format="%H"'),
|
|
'Option A must iterate git log commits to find the hash-matching baseline'
|
|
);
|
|
});
|
|
|
|
test('Option A has a fallback to first-add heuristic when no pristine hash is available', () => {
|
|
const optionAStart = content.indexOf('### Option A');
|
|
const optionBStart = content.indexOf('### Option B');
|
|
const optionABlock = content.slice(optionAStart, optionBStart);
|
|
assert.ok(
|
|
optionABlock.includes('diff-filter=A') || optionABlock.includes('Fallback') || optionABlock.includes('fallback'),
|
|
'Option A must include a fallback for repos without pristine_hashes (older installer)'
|
|
);
|
|
});
|
|
|
|
test('Option A explains why first-add commit is wrong for multi-cycle repos', () => {
|
|
const optionAStart = content.indexOf('### Option A');
|
|
const optionBStart = content.indexOf('### Option B');
|
|
const optionABlock = content.slice(optionAStart, optionBStart);
|
|
assert.ok(
|
|
optionABlock.includes('first add') || optionABlock.includes('first added') ||
|
|
optionABlock.includes('multiple') || optionABlock.includes('update cycles'),
|
|
'Option A must document why the first-add heuristic fails for multi-cycle repos'
|
|
);
|
|
});
|
|
});
|