Skip to content

Restore Previous Commit Message on Undo Last Commit - #9796

Merged
João Moreno (joaomoreno) merged 2 commits into
masterfrom
unknown repository
Aug 12, 2016
Merged

João Moreno (joaomoreno) merged 2 commits into
masterfrom
unknown repository

Conversation

@ghost

Copy link
Copy Markdown

This relates to issue #6190.

I've gone ahead and reimplemented the getLog method, modeling almost exactly the getCommitTemplate method along the way.

I've also implemented the consuming part of this similar as before, using IStorageService. I adjusted it to avoid the bug of blanking out the commit msg when unstaging a file. It also works for consecutive calls to "Undo Last Commit".

If you think there is a better way than using IStorageService, then it should be easy enough to change with how I separated these two commits. As it is though, it is working on my machine (Ubuntu 16.04).

* Added `getLog` method to `Repository`.
  * Added `ILogOptions` to make the method friendlier to extension.
  * Options include `prevCount` and `format`, to effect our use case which is `git log -1 format=%B`.
* Added this to the client-server communication pipeline.
* Added line in `UndoLastCommitAction` to get the previous commit msg and store in `IStorageService`.
* Added `UpdateCommitInputPrevCommitMsg` that checks for that key in storage, and use it then remove it if it exists.
  * This does not suffer from the previous bug that blanked out the commit msg if you unstage a file.
  * Added a clause if the undo last commit fails to remove the key from storage. This way, it doesn't stay in there and get used later (I was scratching my head when it showed up later).
@msftclas

Hi @bill-mybiz, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by Microsoft and real humans are currently evaluating your PR.

TTYL, MSBOT;

@ghost

Copy link
Copy Markdown
Author

I didn't see the "automagically assigned to X" thing, so I'm going to shout out to João Moreno (@joaomoreno) here.

@joaomoreno

Copy link
Copy Markdown
Contributor
  • Instead of getLog, made a simpler getCommit
  • Removed the dependency on storage service and rely on the OPERATION_START event to be able to call git to get the previous commit message

@ghost

Copy link
Copy Markdown
Author

João Moreno (@joaomoreno) Looks beautiful. Thanks for your help.

@github-actions github-actions Bot locked and limited conversation to collaborators Jul 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

git GIT issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants