-
Notifications
You must be signed in to change notification settings - Fork 0
[dogfood] Review-wide diff summary (DO NOT MERGE) #34
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
Open
sdavisde
wants to merge
2
commits into
main
Choose a base branch
from
dogfood/diff-review-summary
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
|
sdavisde marked this conversation as resolved.
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Review summary model | ||
|
|
||
| `diff::summarize` rolls a whole review up into one `ReviewSummary`, so the | ||
| question "how big is this, and where should I start?" is answerable without | ||
| walking hunks at a render surface. | ||
|
|
||
| ## What it reports | ||
|
|
||
| | Field | Meaning | | ||
| | --- | --- | | ||
| | `files` | Every file in the review — binary and rename-only included. | | ||
| | `binary_files` | How many of those are binary. | | ||
| | `content_files` | Files whose content actually changed (added, deleted, modified) and that carry at least one changed line. | | ||
| | `stat` | Added/removed lines summed across the review. | | ||
| | `largest_file` | The file with the most changed lines, as a `Hotspot { path, stat }`. | | ||
| | `largest_hunk` | The biggest single hunk's changed-line count, across all files. | | ||
|
|
||
| ## Counting rules | ||
|
|
||
| **Churn, not net.** `DiffStat::total()` is `added + removed`, so a line | ||
| rewritten in place counts twice — once on each side. That's deliberate: the | ||
| measure exists to estimate how much there is to *read*, and rewriting a line | ||
| means reading two. `DiffStat::net()` is there for the cases that want the | ||
| signed difference instead. | ||
|
|
||
| **Context lines never count.** A hunk with two changed lines and forty lines | ||
| of context is a two-line hunk as far as the summary is concerned. This | ||
| matches `Hunk::stats`, which has always excluded context. | ||
|
|
||
| **Binary files count as files, never as lines.** A line count over binary | ||
| content is meaningless, so binary files land in `files` and `binary_files` | ||
| and are skipped entirely for `stat`, `largest_file`, and `largest_hunk`. | ||
| This is the same call `stat_display` makes when it renders `bin` instead of | ||
| `+0 -0`. | ||
|
|
||
| **Rename-only changes count as files, not content changes.** A pure rename | ||
| carries no hunks, so it contributes to `files` but not to `content_files` — | ||
| `FileChangeKind::is_content_change` draws that line. | ||
|
|
||
| **Ties keep the earlier file.** When two files carry identical churn, | ||
| `largest_file` reports whichever came first in the input. Callers keep the | ||
| file list path-sorted, so the tiebreak is stable and path-ordered rather | ||
| than arbitrary. | ||
|
|
||
| ## Where the numbers come from | ||
|
|
||
| `build_review` computes the summary once, on the background snapshot build, | ||
| and hands it to the UI on `ReviewSnapshot`. Render surfaces read the | ||
| precomputed value; nothing recomputes it per frame. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,16 @@ impl FileChangeKind { | |
| } | ||
| } | ||
|
|
||
| /// Whether this kind implies the file's content changed. A rename or | ||
| /// copy may carry hunks or be path-only; every other kind always | ||
| /// carries content. | ||
| pub fn is_content_change(self) -> bool { | ||
|
Owner
Author
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. [issue] What is this function doing?
Owner
Author
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. nothing important. why? |
||
| matches!( | ||
| self, | ||
| FileChangeKind::Added | FileChangeKind::Deleted | FileChangeKind::Modified | ||
| ) | ||
| } | ||
|
|
||
| /// Derives the change kind from a raw patch's header text and metadata. | ||
| fn from_raw(patch: &RawFilePatch) -> FileChangeKind { | ||
| if patch.raw.contains("\nnew file mode ") { | ||
|
|
||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
[praise] I like how you fixed this grammar
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.
thank yoU!