fix(hooks): a command with several merges says its run evidence is not shown
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
29b1fba9fb
commit
ff3e20919e
4 changed files with 566 additions and 5 deletions
|
|
@ -240,3 +240,30 @@ export function evidenceLines(repoRoot, mergeArgs) {
|
|||
return UNREADABLE;
|
||||
}
|
||||
}
|
||||
|
||||
/** The text for a command with several merges into main (N = the count). */
|
||||
const MANY_MERGES = (n) =>
|
||||
`Tested by: not shown (this command merges ${n} branches into main; merge one at a time to see each run's evidence).\nUndone by: not shown.`;
|
||||
|
||||
/**
|
||||
* The evidence text for every merge approval of one command, for the guard's
|
||||
* question: zero merges give '', one gives its two evidence lines (exactly
|
||||
* evidenceLines), two or more give MANY_MERGES with the count: one question
|
||||
* cannot show each run's evidence, so none is shown.
|
||||
* @param {Array<{subject: string, merge: {args: string[]}}>} merges
|
||||
* @returns {string} never throws
|
||||
*/
|
||||
export function evidenceForMerges(merges) {
|
||||
try {
|
||||
if (!Array.isArray(merges)) return UNREADABLE;
|
||||
if (merges.length === 0) return '';
|
||||
if (merges.length === 1) {
|
||||
const m = merges[0];
|
||||
if (!isObj(m)) return UNREADABLE;
|
||||
return evidenceLines(m.subject, m.merge && m.merge.args);
|
||||
}
|
||||
return MANY_MERGES(merges.length);
|
||||
} catch {
|
||||
return UNREADABLE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue