Fix Microsoft #71258 - Cannot undo empty commits#72699
Merged
joaomoreno merged 3 commits intomicrosoft:masterfrom Aug 8, 2019
Merged
Fix Microsoft #71258 - Cannot undo empty commits#72699joaomoreno merged 3 commits intomicrosoft:masterfrom
joaomoreno merged 3 commits intomicrosoft:masterfrom
Conversation
…nsistent across other methods of committing to git through VS Code
… previous it would think commits with empty messages were invalid when infact they are not
Contributor
Author
|
If anyone could guide me on what's causing these failure in check I would appreciate it. I am unsure of what is going wrong and how to fix it. |
…space, since this is not part of the original issue
Contributor
Author
|
I reverted an earlier commit I made that prevented the user from being able to create commits with only whitespace. I figured since this was explicitly not part of the original issue, it is something that should be changed in a different place. |
joaomoreno
reviewed
Aug 8, 2019
Member
There was a problem hiding this comment.
Good investigation but the fix breaks the Undo behavior of populating the input box with the commit message. By removing that 4th capture group, you lost the commit message for commits which do have a message. I've pushed daf581d instead.
I've merged your PR anyway, since you drove me to the right fix. Thanks! 🍻
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a fix for #71258
I've noticed that in this bug there are essentially two parts to it. If VS Code tries to undo a commit where there was an empty commit message, or a commit message with only whitespace, the "Bad Commit" error occurs.
Furthermore, there is a way to make a commit with just whitespace through VS Code. If you press the tick by Source Control: Git, enter some whitespace, and then press enter, the commit goes through with the message being whitespace. If you try to undo this, the same error will occur.
Fix: Can make commits with only whitespaceI have put this as an error because when filling out a message for a commit in the side bar if there is only whitespace, it will refuse commits. Hence going by that, I am extrapolating that to mean that any commit messages drafted in the top bar should refuse whitespace too.I've removed the second as a requirement because the issue does not explicitly call for a fix on that.
By testing with different commits it seems the regex matching expression is at fault.
The string that goes into the regex match is as follows:
The last part, the name of this commit, is optional, and is not present when there is an empty git commit, but the regex expression looks for it, and hence sees the expression as invalid.
Finally the change in commands.ts makes it so that when whitespace is added as a commit message, the function returns and the window is dismissed. This is the same behaviour as when Enter is pressed (without typing anything) and the window is dismissed. Below is a screenshot of the window.When enter is pressed, the window is dismissed.The above has been reverted to its original behaviour.