Skip to content

Commit 3c6885b

Browse files
committed
test(eager-closure): request rename pairing explicitly in the deleted-source probe
PR #3298 re-review: the probe leaned on git's DEFAULT pairing, so a diff.renames=false gitconfig would have listed every re-homed split hub as deleted source and refused honest splits. --find-renames now states the requirement in the argv; verified in a scratch repo that the pairing survives the hostile config while the old argv leaks the hub under it. Docstrings follow the argv.
1 parent df95c94 commit 3c6885b

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

‎scripts/__tests__/committed-source-tree.ts‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,30 @@ export function renamedSince(repoRoot: string, base: string): ReadonlyMap<string
5555
}
5656

5757
/**
58-
* Production source paths tracked at `base` but gone from the working tree. Plain `git diff`
59-
* already pairs renames by default, so this lists only the deletions that pairing did NOT
60-
* absorb -- a moved-and-rewritten module the detector could not pair, which `renamedSince`
58+
* Production source paths tracked at `base` but gone from the working tree. The diff requests
59+
* rename pairing explicitly (`--find-renames`, so a `diff.renames=false` gitconfig cannot
60+
* weaken it), and --diff-filter=D drops the paired ones, so this lists only the deletions that
61+
* pairing did NOT absorb -- a moved-and-rewritten module the detector could not pair, which
62+
* `renamedSince`
6163
* answers by detection and therefore misses. The split tolerance reads these paths' content
6264
* through `movedFromDeletedSource`: two or more statements shared with ONE deleted source is a
6365
* move signal, so a verbatim transplant stays non-novel; one shared statement is tolerated as
6466
* coincidence, and a statement-by-statement rewrite evades a textual match. This probe is the
6567
* reinforcement -- containment is what structurally refuses a dropped-and-swapped base module
66-
* (#3298 review). The default pairing is load-bearing:
67-
* it keeps a split's re-homed hub OUT of this list (paired to its closest part), and passing
68-
* `--no-renames` would put it here, making the split's own parts share two statements with
69-
* "deleted source" and refusing the very extraction the tolerance exists for.
68+
* (#3298 review). And the pairing itself is load-bearing: it keeps a split's re-homed hub OUT
69+
* of this list (paired to its closest part), while disabling it (--no-renames, or the gitconfig
70+
* the explicit flag overrides) would put the hub here, making the split's own parts share two
71+
* statements with "deleted source" and refusing the very extraction the tolerance exists for.
7072
*/
7173
export function deletedSourcesSince(repoRoot: string, base: string): string[] {
72-
const status = git(repoRoot, ['diff', '--name-only', '--diff-filter=D', '-z', base]);
74+
const status = git(repoRoot, [
75+
'diff',
76+
'--name-only',
77+
'--find-renames',
78+
'--diff-filter=D',
79+
'-z',
80+
base,
81+
]);
7382
return status
7483
.toString('utf8')
7584
.split('\0')

‎scripts/__tests__/eager-closure-budgets.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ import {
6363
* - Cost: one unit-lane test file plus two data/reader modules; five git processes for the
6464
* merge-base side (merge-base, ls-tree, one cat-file batch for the whole base tree — which is
6565
* also where the novelty check reads a deleted source's statements — one rename diff, and one
66-
* default-pairing delete diff listing only the deletions rename detection did not absorb),
66+
* default-pairing (requested via --find-renames, not left to gitconfig) delete diff listing
67+
* only the deletions rename detection did not absorb),
6768
* no device. The
6869
* walker memoizes per-file edges per tree and parses each file once per distinct content, so
6970
* the base tree pays only for the files the branch changed.

0 commit comments

Comments
 (0)