mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-30 11:53:55 +01:00
/gstack-ship no longer lets anyone buy an extra review round or a narrow re-check. After two review rounds, a blocking finding ships only as an owner's recorded ruling, or the PR waits. Why: these paths were switched off last release and kept breaking; four PRs in one day tried to repair them. This is part 4 of the approved /gstack-ship simplification. Nothing to do: each removed flag now refuses with a message that names what replaced it. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/specialist-batched#1 reader=security Review-Finding: p2/outside-voice#3 reader=outside-voice Review-Finding: p2/adversarial-native#1 reader=adversarial-native Review-Finding: p2/adversarial-native#3 reader=adversarial-native Review-Finding: p2/adversarial-native#6 reader=adversarial-native
58 lines
3.3 KiB
TypeScript
58 lines
3.3 KiB
TypeScript
/**
|
|
* GST-2968 follow-up (#4449's read-only final review): a round grant applies at another head only when the PR's own lines are
|
|
* the same there. ownLinesSame compared zero-context patch-ids, which ignore where a hunk sits, so moving the PR's own audit()
|
|
* call from publicTask() into privateTask() kept the grant. It now also compares each own hunk's place, carried through the
|
|
* base's changes, so a pure base merge still keeps the grant.
|
|
*/
|
|
import { afterEach, describe, expect, setDefaultTimeout, test } from 'bun:test';
|
|
import { ownLinesSame } from '../lib/own-lines';
|
|
import { shipFixture, type ShipFx } from './helpers/ship-bin-fixture';
|
|
|
|
setDefaultTimeout(60_000);
|
|
const fxs: ShipFx[] = [];
|
|
afterEach(() => { while (fxs.length) fxs.pop()!.cleanup(); });
|
|
|
|
const task = (pub: string[], priv: string[], top: string[] = []) =>
|
|
[...top, 'export function publicTask() {', ...pub, ' return 1;', '}', '', 'export function privateTask() {', ...priv, ' return 2;', '}', ''].join('\n');
|
|
const AUDIT = ' audit();';
|
|
|
|
function granted(): { f: ShipFx; head: string; same: (b: string) => boolean } {
|
|
const f = shipFixture({ 'src/task.ts': task([], []) }, { 'src/task.ts': task([AUDIT], []) });
|
|
fxs.push(f);
|
|
const head = f.git('rev-parse', 'HEAD').stdout.trim();
|
|
return { f, head, same: b => ownLinesSame(f.work, 'origin/main', head, b) && ownLinesSame(f.work, 'origin/main', b, head) };
|
|
}
|
|
const tip = (f: ShipFx) => f.git('rev-parse', 'HEAD').stdout.trim();
|
|
const mergeBase = (f: ShipFx, files: Record<string, string>, resolved?: Record<string, string>) => {
|
|
f.advanceBase(files);
|
|
f.git('fetch', '-q', 'origin');
|
|
if (f.git('merge', '-q', '--no-edit', 'origin/main').status === 0) return;
|
|
expect(resolved).toBeDefined();
|
|
f.write(resolved!);
|
|
f.commit('merge main');
|
|
};
|
|
|
|
describe('a round grant follows the PR\'s own lines, not just their text (GST-2968)', () => {
|
|
// Value: protects=a grant recorded at one head does not open a round at a head whose own code moved; fails_when=moving audit()
|
|
// between functions with no base change still matches; seam=ownLinesSame as grantFor calls it; no_claim=other grant fields
|
|
test('moving the PR\'s own line to another function needs a new grant', () => {
|
|
const { f, same } = granted();
|
|
f.write({ 'src/task.ts': task([], [AUDIT]) });
|
|
f.commit('move audit into privateTask');
|
|
expect(same(tip(f))).toBe(false);
|
|
});
|
|
|
|
// Value: protects=negative controls: a pure base merge that moves the PR's own hunk down still matches, and a base edit right next
|
|
// to that hunk does not; fails_when=the place check breaks base-merge grants (ghome#17) or carries a hunk the base touched;
|
|
// seam=ownLinesSame
|
|
test('a base merge that only shifts the own line still matches; a base edit beside it does not', () => {
|
|
const shifted = granted();
|
|
mergeBase(shifted.f, { 'src/task.ts': task([], [], ['// header', '// added by main', '']), 'src/c.ts': 'export const c = 3;\n' });
|
|
expect(shifted.same(tip(shifted.f))).toBe(true);
|
|
const beside = granted();
|
|
const typed = (s: string) => s.replace('export function publicTask() {', 'export function publicTask(): number {');
|
|
mergeBase(beside.f, { 'src/task.ts': typed(task([], [])) }, { 'src/task.ts': typed(task([AUDIT], [])) });
|
|
expect(beside.same(tip(beside.f))).toBe(false);
|
|
});
|
|
});
|