code
code copied to clipboard
Add Git reset to changed file context menu
It would be super handy to be able to reset a file to its state according to Git. I think the sane place would be its context menu in the project sidebar. But now I also wonder if there's overlap with the "Restore this file" item in the headerbar?
I'll look into this tackling this issue, since I've been toying around with libgit2 for some other stuff.
If there are no objections, I'd like to move all the libgit2 code in ProjectFolderItem into a GitProjectManager or ProjectGitManager (open to other names, depending on your preferences) since its currently a violation of separation of concerns. Ideally all libgit2 calls should be made within GitProjectManager, to centralize all the obtuse libgit2 code.
I believe @davidmhewitt did most of that work, I'd be curious to hear his thoughts!
I'm happy to implement it in whichever way the maintainers prefer.
@ChristopherNugent Have you made any progress on this?
"Restore this file" only resets changes to the file made since it was opened. It is possible that Code was opened and closed more than once and edits made to a file in multiple sessions, in which case this function would not restore the file according to Git.