Skip to content

Count removed SQL comment lines in software map diff counts - #1554

Open
connorburgess wants to merge 1 commit into
devdotfast:mainfrom
connorburgess:fix/software-map-dash-comments
Open

connorburgess wants to merge 1 commit into
devdotfast:mainfrom
connorburgess:fix/software-map-dash-comments

Conversation

@connorburgess

Copy link
Copy Markdown

I found this while reading how the software map turns a diff into per-element counts. A removed SQL, Lua or Haskell comment line such as -- old comment shows up in a git diff as --- old comment, and an added line that starts with ++ shows up as +++ .... splitGitDiff in packages/review/src/software-map-diff-counts.ts (lines 469-470) checks every line of a file section for --- and +++ , including lines inside hunks, so those rows were taken as file headers. With git diff -U0 of a file q.sql that removes -- old comment and adds ++ not really, q.sql got no counts on either side. With a hunk of -select 1;, --- c, +select 9;, the head side counted one deletion instead of two and the base side put the change on a file called c.

Now --- and +++ are only read as file names before the section's first @@ hunk header. Once a hunk starts, its +, -, space and \ rows stay hunk content until a line that is none of those (the next diff --git, or any other section start), so the headers of the following file are still read as headers.

The new test "counts hunk lines whose content starts with -- or ++ as changes" in software-map-diff-counts.test.ts uses that real git diff -U0 output followed by a second file, and checks both sides. It fails on main 4793780 (expected [ 'src/example.ts' ] to deeply equal [ 'q.sql', 'src/example.ts' ]) and passes on this branch. Checks on this branch: pnpm lint (Found 0 warnings and 0 errors), pnpm format:check (All matched files use the correct format), the CI typecheck pnpm -r --filter '!@dev.fast/review-desktop' --filter '!./diffr/**' --if-present typecheck (exit 0), and pnpm --filter @dev.fast/whiteboard test (Test Files 132 passed | 2 skipped, Tests 1352 passed | 8 skipped). Reproduced with real git output on macOS; covered by a Node test.

The desktop build (pnpm run ci) was not run here; CI runs it. This was not checked in an isolated Desktop.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant