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

Improve squash merge commit message #331

Closed
philipstarkey opened this issue Jun 25, 2020 · 7 comments
Closed

Improve squash merge commit message #331

philipstarkey opened this issue Jun 25, 2020 · 7 comments
Assignees
Labels
improvement An improvement to existing functionality
Milestone

Comments

@philipstarkey
Copy link

Describe the improvement that you'd like
Right now, when you do a squash merge using git-graph it uses a commit message along the lines of:
Merge commit 'd8b8343f10ee8235a113a9f18a5b07fe2fa474c3'

A much more detailed message is written to .git/SQUASH_MSG and is automatically used if you were to manually do the commit using:
git commit or git commit --no-edit

It would be very useful if there was an option for git-graph to use that detailed squash merge message automatically (basically run git commit --no-edit instead of git commit -m "<one-line git graph message>"). Right now I'm ticking the "squash commits" and "no commit" checkboxes when doing the merge from git-graph and then manually running git commit --no-edit from a terminal.

@philipstarkey philipstarkey added the improvement An improvement to existing functionality label Jun 25, 2020
@mhutchie
Copy link
Owner

Hi @philipstarkey,

Thanks for raising this improvement request! I wasn't aware of the SQUASH_MSG file, thanks for letting me know.

From what I can see, when git merge <branch> --squash is followed by git commit --no-edit, a message of the following format is used for the commit:

Squashed commit of the following:

commit d3b7ca77ac44868d3a223cb6404036d2f8069f30
Author: Michael Hutchison <test@mhutchie.com>
Date: Sun Jan 19 11:18:41 2020 +1100

    Commit Message
...

This means that the commit subject (what is shown in the Description column of Git Graph), is just "Squashed commit of the following:".

There doesn't appear to be a way with git commit for to prepend the SQUASH_MSG with a nice one-line subject (e.g. "Merge branch 'test'").

If you're fine with this, please let me know as I'd be happy to add an extension setting to let users choose their preferred format (the existing behaviour, or SQUASH_MSG).

@philipstarkey
Copy link
Author

Hi @mhutchie,

Yes, an option as you suggest in the extension settings to use the default squash commit message would be excellent!

As an possible extension to this, I was wondering if the selection of "squash commits" and "no commit" when merging with git graph could result in the VS Code git commit message box being prepopulated with the commit message? That way people could modify the message prior to committing (if they didn't like the first line or if they wanted to add additional information). I believe prepopulating the VS Code commit message box is possible because the VS Code GitHub Pull Request extension does it when you "start working on an issue". Happy to open this as a separate feature request if you would prefer them to be separate (the idea just occurred to me after you said the commit subject wasn't very informative in the squash message!)

@mhutchie mhutchie added this to the v1.25.0 milestone Jun 25, 2020
@mhutchie
Copy link
Owner

@philipstarkey,

Thanks for confirming that this will work for you, I'll add the extension setting in the next few days.

As for "squash commits" and "no commit": The Visual Studio Code Git Extension's Message Input is automatically populated with the contents of .git/MERGE_MSG, however they don't appear to do the same for .git/SQUASH_MSG. I think this should be raised as a feature in the vscode repository, as then anyone doing a squash merge can benefit from modifying the squash message in the Visual Studio Code Git Extension (not just Git Graph users).

Out of curiosity I had a look at how vscode-pull-request-github populates the commit message (see here): As the extension is made by Microsoft they integrate with the Visual Studio Code Git Extension's repository representation, which allows access to set the input field. I've deliberately avoided using the Visual Studio Code Git Extension's repository representation, as they have many restrictions that would have prevented heaps of functionality that is available in Git Graph - things most Git Graph users take for granted. It would be a mess to be dealing with both Git Graph's repository representation and the Visual Studio Code Git Extension's.

@philipstarkey
Copy link
Author

As for "squash commits" and "no commit": The Visual Studio Code Git Extension's Message Input is automatically populated with the contents of .git/MERGE_MSG, however they don't appear to do the same for .git/SQUASH_MSG. I think this should be raised as a feature in the vscode repository, as then anyone doing a squash merge can benefit from modifying the squash message in the Visual Studio Code Git Extension (not just Git Graph users).

That makes sense! I've logged it as microsoft/vscode#101078

mhutchie added a commit that referenced this issue Jun 28, 2020
…uash commit that is created when the "Squash Commits" option is selected on the Merge & Pull Branch Dialogs respectively.
@mhutchie
Copy link
Owner

This will be available in v1.25.0.

If you'd like to use it before the next release, you can download v1.25.0-beta.2, and install it following the instructions provided here.

@positron96
Copy link

Hi guys. I think I am having a problem related to this.

I am using Git graph extension (which is great!) to start an interactive rebase (not merge), where I squash some commits.
After closing file with rebase commands I am presented with a COMMIT_EDITMSG file that initially contains a lot of comments about what commits are picked etc.
I remove all of the comments and arrange proper commit message, close the editor (by clicking the tick mark button),
but the resulting commit message contains the unmodified commit message starting with comments and everything.

I looked into .git folder and there is a SQUASHMSG with all the comments, along with COMMIT_EDITMSG that I edit in vscode. However even deleting that file does not change anything. So far I haven't found a way to change the resulting commit message (except amending the commit later).

@positron96
Copy link

Ah wait, I think it worked the second time I tried it. It was probably a case of git graph not refreshing itself automatically, so I was looking at a commit made during the process of rebasing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement An improvement to existing functionality
Projects
None yet
Development

No branches or pull requests

3 participants