Repository navigation
Count removed SQL comment lines in software map diff counts - #1554
Open
connorburgess wants to merge 1 commit into
Open
connorburgess wants to merge 1 commit into
connorburgess wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 commentshows up in a git diff as--- old comment, and an added line that starts with++shows up as+++ ....splitGitDiffin 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. Withgit diff -U0of a file q.sql that removes-- old commentand 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 calledc.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 nextdiff --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 -U0output 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 typecheckpnpm -r --filter '!@dev.fast/review-desktop' --filter '!./diffr/**' --if-present typecheck(exit 0), andpnpm --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.