Adding .git/SQUASH_MSG detection to commit message auto-fill #101078#101114
Adding .git/SQUASH_MSG detection to commit message auto-fill #101078#101114joaomoreno merged 5 commits intomicrosoft:masterfrom daniel-j-davis:feature/add-git-squash-message
Conversation
extensions/git/src/repository.ts
Outdated
| async getInputTemplate(): Promise<string> { | ||
| const mergeMessage = await this.repository.getMergeMessage(); | ||
| const squashMessage = await this.repository.getSquashMessage(); | ||
| const commitMessage = await this.repository.getMergeMessage() || await this.repository.getSquashMessage(); |
There was a problem hiding this comment.
No I don't think that's correct. You should use Promise.all(). Or even Promise.race() since we really only care about whether one of them succeeds.
There was a problem hiding this comment.
Will look into implementing this now, haven't really used Promise.race() but familiarising myself with it and working on implementation now. I'll comment here once my commits are final with Promise.race() implemented. Sorry about that.
There was a problem hiding this comment.
Is using Promise.race() going to require some refactoring of those two functions and what they return, though? Seems like Promise.race() will stop at the first promise resolution or rejection, unless I'm misunderstanding it.
EDIT: I guess we could do... const [mergeMessage, squashMessage] = await Promise.all([this.repository.getMergeMessage(), this.repository.getSquashMessage()]);, would that be appropriate?
There was a problem hiding this comment.
Yeah we'd kind of need Promise.any which isn't available. Let's maybe just do Promise.all and use the first non undefined result.
There was a problem hiding this comment.
How's that (latest commit)? Hopefully this hits the nail on the head!
This PR fixes #101078
As discussed in the issue, just like
.git/MERGE_MSGis auto-filled if there's no commit message in the box,.git/SQUASH_MSGshould also be auto-filled if present. This behaviour works the same way as git-gui does, in the sense thatMERGE_MSGhas precedence overSQUASH_MSG, so it looks for MERGE first, then SQUASH.This can be tested by using the
git merge <branch> --squashcommand, or alternatively, going into the.gitdirectory and addingSQUASH_MSGwith some commit message inside.