Improve blame ranges - #2204
Merged
Sebastian Thiel (Byron) merged 6 commits intoNov 1, 2025
Merged
Improve blame ranges#2204
Conversation
Co-authored-by: Bart Dubbeldam <bartdubbeldam2000@gmail.com>
Co-authored-by: Bart Dubbeldam <bartdubbeldam2000@gmail.com>
This modification introduces changes to the `BlameRanges` struct, converting it into an enum to support both `PartialFile` and `WholeFile`. Internally the ranges in `BlameRanges` are stored as zero-based exclusive ranges now. Co-authored-by: Bart Dubbeldam <bartdubbeldam2000@gmail.com>
Co-authored-by: Bart Dubbeldam <bartdubbeldam2000@gmail.com>
The comment was referring to previous versions of the code.
Member
|
Did you say this is ready for merging and hanging on me? |
Contributor
Author
|
Yes! If I remember correctly, nothing is missing from my side (though it has been a couple of weeks since I last touched this PR 😅). |
Byron
approved these changes
Nov 1, 2025
Byron
left a comment
Member
There was a problem hiding this comment.
Sorry for the long wait, I don't know what happened there.
Hopefully this only happens once a year or so 😅.
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.
This PR is a continuation of #1976. I took the original PR by Bart Dubbeldam (@holodorum) and applied the suggestions I had given in my reviews of his PR. I also added a few tests and adapted some parts to
gitoxide’s conventions.These are the most important changes:
rangetorangesthat was done so the variable name now corresponds to the type nameBlameRanges.BlameRangesinto an enum, to more idiomatically cover the special caseWholeFile.BlameRangeskeeps its ranges sorted as that is important for the blame algorithm.There’s one decision that requires particular attention. When you add a range to a
WholeFile, it is turned into aPartialFilecontaining the given range. This mirrors the difference ofgit blamevs.git blame -L a,b. The initial version of the PR returned an error instead, but that makes the API less ergonomic, so I decided to make the change.