mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-17 13:44:32 +01:00
Accept a requested docs fix when the audit names the file with a line number (#4437)
finish --docs-requested refused a correct fix when the docs audit named the
file as path:line ("changelog.d/engine-parity-decisions.md:8: wording") or
path:line:column, because the match only allowed whitespace, quotes or
punctuation right after the path. It now also allows :<line> and
:<line>:<column> before those, while a different file sharing the path's
prefix still doesn't match. Reported by Vorflux via FOUN-32.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
e66a772722
commit
127bcd6d55
3 files changed
+24
-1
No files matched your search
@@ -0,0 +1 @@
|
||||
- **/ship's `finish --docs-requested` now accepts a docs fix when the audit named the file with a line number.** An audit that wrote `changelog.d/engine-parity-decisions.md:8: wording` or `...md:8:12 wording` in its blockers or decisions was refused with "is not named in the audit result's blockers or decisions", even though `...md: line 8` worked. The path may now be followed by `:<line>` or `:<line>:<column>`. A different file whose name starts with the same path still doesn't match.
|
||||
+1
-1
@@ -546,7 +546,7 @@ function docsFresh(cwd: string, base: string, postFile: string, moved: readonly
|
||||
try { audit = resultFile ? JSON.parse(fs.readFileSync(resultFile, 'utf8')) : null; } catch { audit = null; }
|
||||
for (const p of requested.filter(q => stale!.includes(q) && !carried.tests.includes(q) && !carried.base.includes(q) && !carried.accepted.includes(q))) {
|
||||
const asked = [...(Array.isArray(audit?.blockers) ? audit.blockers : []), ...(Array.isArray(audit?.decisions) ? audit.decisions : [])].filter((s: unknown) => typeof s === 'string');
|
||||
const token = new RegExp(`(^|[\\s\`'"(\\[])${p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?=$|[\\s\`'")\\]]|[,.:;](?:$|\\s))`);
|
||||
const token = new RegExp(`(^|[\\s\`'"(\\[])${p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?::\\d+(?::\\d+)?)?(?=$|[\\s\`'")\\]]|[,.:;](?:$|\\s))`);
|
||||
const stat = git(cwd, ['diff', '--numstat', '--no-renames', record.head, '--', `:(literal)${p}`]).stdout.trim().split(/\s+/);
|
||||
const lines = Number(stat[0]) + Number(stat[1]);
|
||||
const why = !audit ? 'needs --docs-result <the audit\'s saved result JSON>'
|
||||
|
||||
@@ -554,6 +554,28 @@ describe('test-only and audit-requested edits after the docs audit (GST-391, gbr
|
||||
expect(big.stdout).toContain('STOP: --docs-requested docs/KEY_FILES.md');
|
||||
});
|
||||
|
||||
// Value: protects=an audit that names the requested doc as path:line or path:line:column (FOUN-32 via Vorflux at 2af3822f)
|
||||
// still backs the fix, while a different file sharing the path's prefix never does; fails_when=a correct requested fix stops
|
||||
// on how the audit wrote the location, or a sibling file's note waves the fix through; seam=finish --docs-requested;
|
||||
// no_claim=the audit child's wording
|
||||
test.each([
|
||||
['path:line', 'docs/KEY_FILES.md:8: the src/b.ts entry is missing', true],
|
||||
['path:line:column', 'docs/KEY_FILES.md:8:12 the src/b.ts entry is missing', true],
|
||||
['path then "line"', 'docs/KEY_FILES.md: line 8 is missing the src/b.ts entry', true],
|
||||
['another file sharing the prefix', 'docs/KEY_FILES.md.tmpl:8: the src/b.ts entry is missing', false],
|
||||
])('--docs-requested matches the audit naming the doc as %s: %p', (_name, decision, named) => {
|
||||
const index = Array.from({ length: 30 }, (_, i) => `- entry ${i}`).join('\n') + '\n';
|
||||
const f = fx({ 'docs/KEY_FILES.md': index });
|
||||
const reviewed = wtree(f);
|
||||
const post = snapshot(f, ['docs']);
|
||||
const result = path.join(f.root, 'a1-result.json');
|
||||
fs.writeFileSync(result, JSON.stringify({ schema_version: 1, audit_id: 'a1', status: 'current', files_updated: [], files_reviewed: ['docs/KEY_FILES.md'], blockers: [], decisions: [decision], documentation_section: 'x' }));
|
||||
f.write({ 'docs/KEY_FILES.md': index + '- src/b.ts: the b constant\n' }); f.commit('docs: index link');
|
||||
const r = finish(f, reviewed, post, ['--reviewed-base', mergeBase(f), '--docs-rechecked', '--docs-requested', 'docs/KEY_FILES.md', '--docs-result', result]);
|
||||
if (named) expect([r.status, lineOf(r.stdout, 'DOCS')]).toEqual([0, expect.stringContaining('requested=1')]);
|
||||
else expect(r.stdout).toContain("STOP: --docs-requested docs/KEY_FILES.md is not named in the audit result's blockers or decisions");
|
||||
});
|
||||
|
||||
// Value: protects=an audit launch the child's install check refused is not counted, once per invocation; a crashed child,
|
||||
// a completed audit and output that only quotes a refusal are counted, and a second refusal stops; fails_when=the refusal
|
||||
// burns the only retry (gbrain #8084) or refusals relaunch forever; seam=none; no_claim=the parent's launch
|
||||
|
||||
Reference in new issue
Block a user