Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes are documented here. This project follows Semantic Versionin

### Fixed

- Preserved precise changed-line hunks across renames by scoping per-file Git diffs to both the previous and current path. This prevents a rename with content edits from being reinterpreted as a whole-file addition and overstating changed-line or call-reference evidence.
- Preserved trailing whitespace in Git repository-root paths. `findRepository()` now removes only Git's record line terminator instead of applying JavaScript `String.trim()`, preventing a repository such as `repository ` from being silently redirected to a sibling path with the trimmed spelling.
- Tightened Python test-runner exit-code 5 handling. Pytest and the stdlib `unittest` CLI use code 5 for no-test outcomes, but repository-local modules can also terminate runner imports with code 5 before trustworthy lifecycle observation. ProofDiff now accepts exit 5 as non-failing only when high-confidence exact zero-test observer data corroborates it: directly for targeted pytest, or through the paired targeted observer for opaque pytest/unittest commands. Uncorroborated exit-5 failures remain verification failures.
- Preserved LCOV `SF:` source paths exactly instead of applying JavaScript-style whitespace trimming. Leading or trailing spaces and Unicode whitespace are valid path characters, so silently erasing them could alias artifact coverage for one path onto a different changed repository file and overstate changed-line evidence.
Expand Down
2 changes: 1 addition & 1 deletion dist/git.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion dist/git.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/git.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ export async function changedFiles(root: string, diffArgs: string[], includeUntr
metric = { additions: lines, deletions: 0, binary };
patch = content === null ? "" : `@@ -0,0 +1,${lines} @@\n${content.split("\n").map((line) => `+${line}`).join("\n")}`;
} else {
patch = await git(root, ["diff", ...safeDiffOptions, "--unified=0", "--find-renames", ...diffArgs, "--", entry.path], true);
const pathspec = entry.previousPath === undefined ? [entry.path] : [entry.previousPath, entry.path];
patch = await git(root, ["diff", ...safeDiffOptions, "--unified=0", "--find-renames", ...diffArgs, "--", ...pathspec], true);
}
files.push({
path: entry.path,
Expand Down
43 changes: 43 additions & 0 deletions tests/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,49 @@ test("rename metadata preserves both paths", async (context) => {
assert.equal(file?.change, "renamed");
assert.equal(file?.previousPath, "src/old name.ts");
assert.equal(file?.path, "src/new name.ts");
assert.deepEqual(file?.hunks, []);
});

test("rename with content modification preserves the minimal changed hunk", async (context) => {
const root = await initializeRepository({
"src/foo.js": [
"export function helperA() { return 1; }",
"",
"export function target() {",
" helperA();",
" const x = 1;",
" const y = 2;",
" return x + y;",
"}",
"",
].join("\n"),
});
context.after(() => rm(root, { recursive: true, force: true }));
git(root, "mv", "src/foo.js", "src/bar.js");
await writeFiles(root, {
"src/bar.js": [
"export function helperA() { return 1; }",
"",
"export function target() {",
" helperA();",
" const x = 1;",
" const y = 3;",
" return x + y;",
"}",
"",
].join("\n"),
});
const { args } = await selectDiff(root, {});
const [file] = await changedFiles(root, args, true);
assert.equal(file?.change, "renamed");
assert.equal(file?.previousPath, "src/foo.js");
assert.equal(file?.path, "src/bar.js");
assert.equal(file?.additions, 1);
assert.equal(file?.deletions, 1);
assert.deepEqual(file?.hunks, [{
oldRange: { start: 6, end: 6 },
newRange: { start: 6, end: 6 },
}]);
});

test("staged selection excludes later unstaged edits", async (context) => {
Expand Down