Issue #2234 new

Template for commit message

Chris Coulson
created an issue

It would be nice to be able to set a default/template commit message in thg. With a template message it will result in less errors when adding an issue number to a commit message.

So for example the template might be:

I realize there is already functionality to enforce using an issue # in the commit message - but there may be cases where there is no issue # for the commit - so the committer could just remove the issue # from the message in that case.

Also, this should probably be configurable per repository and apply to everybody who uses the repository - much like the .hgignore file.

Comments (9)

  1. Steve Spencer

    This would be very useful. We used this back when using Svn. We would use a particular template to separate out public vs private parts of the message, for auto-generation in a public changelog of our commercial product.

  2. Steve Spencer

    We're thinking of developing this feature for TortoiseHg, since we want to encourage developers to add structured information to commit messages which we then later use to generate structured changelogs for end-user consumption.

    The simplest change is to add a hgrc setting for "default commit message", and leave enforcement to hooks. The CommitWidget would use this on init and after commit, instead of clearing.

    If we develop this, would you accept this change as described, how should we deliver it, and when would it end up in a Windows EXE installer?

  3. Steve Spencer

    Great! Thanks for the info.

    What sort of timeframe is there between a patch being accepted in default (assuming it does get approved) and the change making its way into the official Windows binaries?

  4. Angel Ezquerra

    Let me make a few of suggestions about this feature, if you guys are going to try to implement it:

    1. It would be nice if it was possible to use some limited set of "template variables" to include revision info in the commit message, perhaps using mercurial style template strings, particularly to include the list of modified or added files (e.g. "{file_adds}", etc).

    2. It should be possible to configure TortoiseHg to have a default commit message template (which is used to initialize the commit message widget) or to configure it to enforce a certain commit message format (which is checked at commit time).

    3. It should be possible to use different templates for merge revisions and regular revisions, or at least to disable the template or the template check for commit revisions. Same thing for backout and tag revisions. Mercurial and TortoiseHg control these, so the user should not be forced to comply with a template in those cases.

  5. Log in to comment