Repository navigation
fix(desktop): preserve diff counts for compact rename paths #8995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,8 +141,13 @@ export function parseDiffNumstat( | |
| isBinary: addStr === "-" && delStr === "-", | ||
| }; | ||
|
|
||
| const compactRenameMatch = rawPath.match(/^(.*?)\{(.*?) => (.*?)\}(.*)$/); | ||
| const renameMatch = rawPath.match(/^(.+) => (.+)$/); | ||
| if (renameMatch) { | ||
| if (compactRenameMatch) { | ||
| const [, prefix, oldPart, newPart, suffix] = compactRenameMatch; | ||
| stats.set(`${prefix}${newPart}${suffix}`, statEntry); | ||
| stats.set(`${prefix}${oldPart}${suffix}`, statEntry); | ||
|
Comment on lines
+144
to
+149
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Prompt To Fix With AIThis is a comment left during a code review.
Path: apps/desktop/src/lib/trpc/routers/changes/utils/parse-status.ts
Line: 144-149
Comment:
**Brace directories lose counts**
`compactRenameMatch` can mistake a literal `{` in a shared directory name for the start of the rename. For example, `src/{shared}/{old => new}/file.ts` produces `src/new/file.ts` and `src/shared}/{old/file.ts`, rather than the two complete paths. The Changes list still loses the counts for this compact rename. Distinguish literal braces from the rename group and add a regression for this case.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly. |
||
| } else if (renameMatch) { | ||
| const oldPath = renameMatch[1]; | ||
| const newPath = renameMatch[2]; | ||
| stats.set(newPath, statEntry); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: ParadevAI/Paradev
Length of output: 9341
Script executed:
Repository: ParadevAI/Paradev
Length of output: 7783
Web query:
site:git-scm.com/docs git diff --numstat rename detection pathnames brace arrow output formatResult:
Do not classify every brace-and-arrow path as a rename.
The plain
--numstatformat does not preserve whethersrc/{old => new}/file.tsis a literal path or compact rename output. The parser expands both forms, soapplyNumstatToFilescannot apply stats to the literal path.Use rename metadata or parse Git’s
--numstat -zformat, which preserves separate preimage and postimage paths. Add a regression test for a literal brace path.