cmt: Write consistent git commit messages

[ bsd3, command-line-tools, library, program ] [ Propose Tags ]
Versions [RSS] 0.2.0.0, 0.3.0.0, 0.4.0.0, 0.5.0.0, 0.6.0.0, 0.7.0.0, 0.7.1.0
Dependencies attoparsec (>=0.13.2.2 && <0.14), base (>=4.7 && <5), classy-prelude (>=1.5.0 && <1.6), cmt, directory (>=1.3.3.0 && <1.4), filepath (>=1.4.2.1 && <1.5), process (>=1.6.3.0 && <1.7), terminal-size (>=0.3.2.1 && <0.4), text (>=1.2.3.1 && <1.3) [details]
License BSD-3-Clause
Copyright Small Hadron Collider / Mark Wales
Author Small Hadron Collider / Mark Wales
Maintainer mark@smallhadroncollider.com
Category Command Line Tools
Home page https://github.com/smallhadroncollider/cmt#readme
Bug tracker https://github.com/smallhadroncollider/cmt/issues
Source repo head: git clone https://github.com/smallhadroncollider/cmt
Uploaded by smallhadroncollider at 2019-03-08T20:05:32Z
Distributions
Executables cmt
Downloads 2565 total (17 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-03-08 [all 1 reports]

Readme for cmt-0.4.0.0

[back to package description]

cmt

Write consistent git commit messages

Install

Binaries for Mac and Linux are available. Add the binary to a directory in your path (such as /usr/local/bin).

Cabal

Requirements: Cabal

cabal install cmt

Make sure you run cabal update if you haven't run it recently.

Building

Requirements: Stack

The following command will build cmt and then install it in ~/.local/bin:

stack build && stack install

Usage

Add a .cmt file to your project directory.

cmt # will show the options and then commit

If you're using the ${*} format option then:

cmt "blah blah blah" # this will go in ${*} place

If there are commit message you use frequently (such as "version bump"), you can setup predefined messages with aliases:

cmt -p vb # use the version bump message

If the commit returns with a non-zero status code, your previous commit message is stored in a .cmt.bkp file. You can re-run the commit when you're ready with:

cmt --prev

Format

A .cmt file consist of two parts: the input parts and the output format.

For example, the AngularJS Commit Message Guidelines:

# The input parts
{
    # Shows a list of options
    "Type" = [
        "feat",
        "fix",
        "docs",
        "style",
        "refactor",
        "test",
        "chore"
    ]
    "Scope" = % # Select from a list of staged files
    "Subject" = @ # Single line input
    "Body" = !@ # Multi-line input
    "Footer" = !@
}

# predefined messages
{
    vb = "chore (package.yaml): version bump"
    readme = "docs (README.md): updated readme"
}

# The output format
# Takes the values provided from the input stage
# and interpolates them in
${Type} (${Scope}): ${Subject}

${Body}

${Footer}

Input Parts

These are at the top of the .cmt file and surrounded by opening and closing curly braces. A consist of a name and a type:

  • @: single line input
  • !@: multi line input
  • %: select from a list of staged files
  • ["option 1", "option 2"]: list of options

Output Format

The output format consists of named input parts plus anything else you want.

You can accept a output called ${*}, which will add in whatever is passed to cmt as command line arguments.

For example:

# Input parts
# * input not needed, as comes from command-line
{
    "Scope" = %
}

# Scope from input and * from command-line
(${Scope}): ${*}

Then use with:

cmt "Blah blah blah"