-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
Add ability to revert hunk #1599
Conversation
this is really great! Some minor tweaks then lets get this merged. |
Reads a bit better Change-Id: I2c5aaa5b68a140de49bd38c10b2dca4b10e15efe
Change-Id: I266a58026636cee04e1d825545df0f047324c068
I'm not sure about these failing tests, if they're my fault or not, because I cannot figure out how to run them locally. |
I don't think it's your fault, and I'll add some instructions on how to do that. (you'll need a ruby runtime (3.3.6) and run |
I tried that but seems my version (3.2.3) of ruby is not compatible. |
No worries - this looks good as is. Thanks for taking the time! |
This PR adds the ability to revert individual hunks from the commit_view.
In order to do this I had to expand the
Hunk
type slightly, so that it can be just by itself with the correspondingDiff
it belongs to. Namely I added two new fields:file
, the name of the file from the where the hunk applieslines
, this was already kind of part of the type except not in the documentation.With these changes, the
generate_patch
can work without being passed anitem
, which doesn't exist in the context of a standalone hunk. It is now also able to parse the lines directly onHunk
, whether it is aSelectedHunk
or not. Thefrom
andto
parameters now represents the relative lines in the hunk buffer.With these changes; reverting a hunk is now only a matter of doing a
git apply --reverse
with a patch fromgenerate_patch
.