lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

Commit prefix for merge commit

Open gikari opened this issue 2 years ago • 6 comments

Is your feature request related to a problem? Please describe.

The remote I work with has a requirement to have a ticket ID in the commit title. For that purpose I use commit prefix feature.

However, when a I merge one branch into another with a merge commit, the merge commit uses default message "merged X into Y".

To fix that I need to go to the browser, copy ticket number, then edit the last commit message manually. This is inconvenient.

Describe the solution you'd like

I would like so that when I do a merge in lazygit, the merge commit message would automatically add the prefix I configured in the lazygit settings.

Describe alternatives you've considered

None.

Additional context

None.

gikari avatar Nov 07 '23 11:11 gikari

Hello gikari,

I have the same need as you, but more complete : use a full template for both commit title and message (we put the ticket number at the message bottom instead of in the title).

In fact, Git already have a template feature, see commit.template configuration. It works well with the git commit command and fine with git gui (with a piece of bash script associated to an alias. I can share it).

So I think that lazygit shall just use the git configuration to find the commit template and use it. That seems reasonably feasible. That is the feature I really miss because it is painful to rewrite everything each time.

If no commit.template configuration defined, Lazygit could just use the last commit title as template by default.

What do you think about ?

GuillaumeHM avatar Dec 19 '23 14:12 GuillaumeHM

So I think that lazygit shall just use the git configuration to find the commit template and use it. That seems reasonably feasible. That is the feature I really miss because it is painful to rewrite everything each time.

Does it work as expected if you use C to commit (Commit changes using git editor)?

mark2185 avatar Jan 07 '24 12:01 mark2185

Yes it does work ! Although there are a couple of disappointing things:

  • Loading time is longer (1-2 seconds).
  • I 'm not writing in a popup with repository metadata informations in background to help me write my commit message (but I'm in vim in the full terminal).

And one good point: I can choose to C or c to respectively write a well formed commit or a temporary one (no need to erase the full template in that case).

To conclude, it is a quite acceptable workaround for my use case but I would prefer not to leave lazygit. Thank you for helping !

GuillaumeHM avatar Jan 08 '24 08:01 GuillaumeHM

If you haven't already, try adding commit.verbose = true in your .gitconfig in order to get more info when you're committing through the git editor.

E.g.:

[commit]
	verbose = true

To conclude, it is a quite acceptable workaround for my use case but I would prefer not to leave lazygit.

Perfectly reasonable :)

This will have to do until proper support for commit.template is supported, or another solution is in place.

mark2185 avatar Jan 08 '24 08:01 mark2185

I didn't known this configuration, that helps. Thank you :)

GuillaumeHM avatar Jan 08 '24 14:01 GuillaumeHM

We are using pre-commit hook for applying conventional commits. Everytime lazygit creates a merge commit I has to fix the commit message before I can continue merging. It would nice if we can set the prefix just to fix:.

MrPeacockNLB avatar Jul 15 '24 08:07 MrPeacockNLB

We also have a commit message format, but is not fixed to anything. I suggest an added option to merge-commit with a custom message.

pknameer avatar Nov 27 '24 05:11 pknameer