Skip to content
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

Merged
merged 6 commits into from
Dec 17, 2024
Merged

Add ability to revert hunk #1599

merged 6 commits into from
Dec 17, 2024

Conversation

kjughx
Copy link
Contributor

@kjughx kjughx commented Dec 15, 2024

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 corresponding Diff it belongs to. Namely I added two new fields:

  1. file, the name of the file from the where the hunk applies
  2. lines, 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 an item, which doesn't exist in the context of a standalone hunk. It is now also able to parse the lines directly on Hunk, whether it is a SelectedHunk or not. The from and to 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 from generate_patch.

@CKolkey
Copy link
Member

CKolkey commented Dec 16, 2024

this is really great! Some minor tweaks then lets get this merged.

Philip Johansson added 2 commits December 16, 2024 15:49
Reads a bit better

Change-Id: I2c5aaa5b68a140de49bd38c10b2dca4b10e15efe
Change-Id: I266a58026636cee04e1d825545df0f047324c068
@kjughx
Copy link
Contributor Author

kjughx commented Dec 16, 2024

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.

@CKolkey
Copy link
Member

CKolkey commented Dec 16, 2024

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 bundle && CI=1 bundle exec rspec --format Fuubar)

@kjughx
Copy link
Contributor Author

kjughx commented Dec 17, 2024

I tried that but seems my version (3.2.3) of ruby is not compatible.

@CKolkey
Copy link
Member

CKolkey commented Dec 17, 2024

No worries - this looks good as is. Thanks for taking the time!

@CKolkey CKolkey merged commit 9dc5807 into NeogitOrg:master Dec 17, 2024
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants