-
-
Notifications
You must be signed in to change notification settings - Fork 346
Support for multiple blame ranges #1973
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
Support for multiple blame ranges #1973
Conversation
93bb148
to
ead0dca
Compare
This update replaces single-range handling with the `BlameRanges` type, allowing multiple 1-based inclusive line ranges to be specified for blame operations. It hides some of the implementation details of the range logic, prepares for compatibility with `git` behavior, and adds tests to validate multi-range scenarios.
…> -L <other-range> ...` Update the blame subcommand to handle multiple line ranges. This allows specifying multiple `-L` options similar to the usage of git.
ead0dca
to
d4461e7
Compare
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.
Thanks so much, this looks great!
Please note that I did refactor the commits to properly indicate breakage with conventional commits, and there are some other refactors too which you might find interesting.
Also CC @cruessler just in case he'd like to see other changes in a follow-up, the reason I merge it already is that it's implemented very non-invasively without basically no changes to the algorithm itself.
Wow that was quick! And thank you, there are some insightful refactors and updates :) |
@holodorum @Byron Just a couple of minor observations, some possibly nitpicky, so feel free to ignore. :-)
Apart from that, I think this is already a great addition! |
Also, I feel there’s a certain contradiction in calling the method |
That are some good suggestions, thanks @cruessler.
|
|
Apologies for being so merge-happy 😅, next time I will wait for your review. |
@Byron No worries! I think we can address all comments in a follow-up PR as you suggest. |
This PR adds support for multiple ranges to blame instead of a single-range. This is compatible with
git
's behavior. Using git it's possible to blame multiple ranges as follows:This results in a blame of lines 1-3 in
example.rs
. After this update we are able to run the same command usinggix
!Initially I tried implementing this without the refactoring to a
BlameRanges
type. However, it became messy quickly because the ranges had the typeOption<Vec<std::ops::Range<u32>>>
type. WithBlameRanges
the complexity is quite comprehensible I feel.A possible improvement could be to add an enum that signals whether the ranges are
zero_based
orone_based
.