{"id":13616785,"url":"https://github.com/smallhadroncollider/cmt","last_synced_at":"2025-04-14T03:31:35.825Z","repository":{"id":62422822,"uuid":"171956102","full_name":"smallhadroncollider/cmt","owner":"smallhadroncollider","description":"Write consistent git commit messages based on a custom template","archived":true,"fork":false,"pushed_at":"2020-10-05T19:04:17.000Z","size":1211,"stargazers_count":189,"open_issues_count":3,"forks_count":9,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-08T14:05:25.540Z","etag":null,"topics":["command-line","formatting","git","git-commit-messages"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smallhadroncollider.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["smallhadroncollider"],"custom":["https://www.buymeacoffee.com/shc"]}},"created_at":"2019-02-21T22:38:06.000Z","updated_at":"2024-03-25T18:14:10.000Z","dependencies_parsed_at":"2022-11-01T17:33:44.923Z","dependency_job_id":null,"html_url":"https://github.com/smallhadroncollider/cmt","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallhadroncollider%2Fcmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallhadroncollider%2Fcmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallhadroncollider%2Fcmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smallhadroncollider%2Fcmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smallhadroncollider","download_url":"https://codeload.github.com/smallhadroncollider/cmt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248815549,"owners_count":21165943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line","formatting","git","git-commit-messages"],"created_at":"2024-08-01T20:01:33.300Z","updated_at":"2025-04-14T03:31:30.814Z","avatar_url":"https://github.com/smallhadroncollider.png","language":"Haskell","funding_links":["https://github.com/sponsors/smallhadroncollider","https://www.buymeacoffee.com/shc"],"categories":["Haskell"],"sub_categories":[],"readme":"# cmt\n\nWrite consistent git commit messages based on a custom template.\n\nSimilar idea to [commitizen](https://github.com/commitizen/cz-cli), but with an emphasis on making it easy to define a custom commit style.\n\n- [Concept](#Concept)\n- [Format](#Format)\n- [Usage](#Usage)\n- [Install](#Install)\n\n![Demo](docs/cmt-0.7.gif)\n\n\n## Concept\n\nIt's important to write consistent commit messages, but depending on the project you may well want to use different commit styles.\n\nWith `cmt` you create a `.cmt` file in your project directory. The `.cmt` file enforces a particular style of commit message for that project. You can also add predefined commit messages for things like version bumps and updating the readme.\n\nFor example, for my programming projects I try to use a commit style similar to the [AngularJS Commit Message Guidelines](https://gist.github.com/stephenparish/9941e89d80e2bc58a153). However, this isn't appropriate for my teaching notes repos or for my capistrano build repos.\n\n\n## Format\n\nA `.cmt` file consist of two parts: the input parts and the output format.\n\nA basic `.cmt` file to include a subject and body would look like:\n\n```txt\n# The input parts\n{\n    \"Subject\" = @ # Single line input\n    \"Body\" = !@ # Multi-line input\n}\n\n# predefined commit messages\n# this section is optional\n{\n    vb = \"version bump\"\n}\n\n# The output format\n${Subject}\n\n${Body}\n```\n\nA more complex example, the [AngularJS Commit Message Guidelines](https://gist.github.com/stephenparish/9941e89d80e2bc58a153):\n\n```txt\n# The input parts\n{\n    # Shows a list of options\n    \"Type\" = [\n        \"feat\",\n        \"fix\",\n        \"docs\",\n        \"style\",\n        \"refactor\",\n        \"test\",\n        \"chore\"\n    ]\n    \"Scope\" = @ # Single line input\n    \"Subject\" = @\n    \"Body\" = !@ # Multi-line input\n    \"Footer\" = !@\n}\n\n# predefined messages\n# this section is optional\n{\n    vb = \"chore: version bump\"\n    readme = \"docs: updated readme\"\n}\n\n# The output format\n# Takes the values provided from the input stage\n# and interpolates them in\n${Type} (${Scope}): ${Subject}\n\n${Body}\n\n${Footer}\n```\n\nFor my capistrano build repos the `.cmt` file is simply:\n\n```txt\n{}\n\n\"latest build\"\n```\n\n\n### Input Parts\n\nThese are at the top of the `.cmt` file and surrounded by opening and closing curly braces. A consist of a name and a type:\n\n- `@`: single line input\n- `!@`: multi line input\n- `%`: select from a list of staged files\n- `[\"option 1\", \"option 2\"]`: list of options\n\n### Predefined Messages\n\nThe predefined messages section is optional. You can provide a list of names and messages and then use the `-p \u003cname\u003e` command-line argument to use one of them.\n\nFor example, with the following config, `cmt -p vb` would use the message \"version bump\".\n\n```txt\nvb = \"version bump\"\n```\n\nPredefined messages can also use any input parts defined in the prior section. An example of this would be:\n\n```txt\n{\n    \"Project\" = [\n        \"ghc\",\n        \"cabal\"\n    ]\n}\n{\n    vb = \"${Project}: version bump\"\n}\n```\n\nRunning `cmt -p vb` will now prompt you to select which project is getting version bumped.\n\n### Output Format\n\nThe output format consists of named input parts (`${\u003cname\u003e}`) plus anything else you want.\n\n#### Wildcard Output\n\nYou can accept an output called `${*}`, which will add in whatever is passed to `cmt` as command-line arguments.\n\nFor example:\n\n```txt\n# Input parts\n# * input not needed, as comes from command-line\n{\n    \"Scope\" = %\n}\n\n# Scope from input and * from command-line\n(${Scope}): ${*}\n```\n\nThen use with:\n\n```bash\ncmt \"Blah blah blah\"\n```\n\n\n## Usage\n\nAdd a `.cmt` file to your project directory.\n\n```bash\ncmt # will show the options and then commit\n```\n\n`cmt` will also look in your home directory if a `.cmt` file isn't found in the project directory hierarchy. This can be used to define a global commit style, which you can then override on a per-project basis.\n\n### Predefined Messages\n\nIf there are commit message you use frequently (such as \"version bump\"), you can setup predefined messages with aliases:\n\n```bash\ncmt -p vb # use the version bump message\n```\n\n### Wildcard Output\n\nIf you're using the `${*}` format option then:\n\n```bash\ncmt \"blah blah blah\" # this will go in ${*} place\n```\n\n### Dry Runs\n\nIf you add `--dry-run` as the first argument, `cmt` will show you the output, but not try and make a commit. It will store the output so you can easily run it without having to re-enter everything.\n\n```bash\ncmt --dry-run \"Blah blah blah\"\ncmt --dry-run -p vb\n```\n\n### Re-run Failed/Dry Run Commits\n\nIf the commit returns with a non-zero status code or you run with `--dry-run`, your previous commit message is stored in a `.cmt.bkp` file. You can re-run the commit when you're ready with:\n\n```bash\ncmt --prev\n```\n\n### Colour Output\n\nBy default the output uses bash colour codes. You can turn this off using the `--no-color` setting.\n\n\n### Other Options\n\n```bash\ncmt -h # displays usage information\ncmt -v # displays version number\ncmt -c # displays location of .cmt file\n```\n\n\n## Install\n\n### Homebrew (Mac)\n\nYou can install `cmt` on your Mac using [Homebrew](https://brew.sh):\n\n```bash\nbrew install cmt\n```\n\n### Debian/Ubuntu\n\n[A `.deb` package is available for Debian/Ubuntu](https://github.com/smallhadroncollider/cmt/releases). Download it and install with `dpkg -i \u003cpackage-name\u003e`.\n\n\n### Binaries\n\n[Binaries for Mac and Linux are available](https://github.com/smallhadroncollider/cmt/releases). Add the binary to a directory in your path (such as `/usr/local/bin`).\n\n### Cabal\n\n**Requirements**: [Cabal](https://www.haskell.org/cabal/)\n\n```bash\ncabal install cmt\n```\n\nMake sure you run `cabal update` first if you haven't run it recently.\n\n### Building\n\n**Requirements**: [Stack](https://docs.haskellstack.org/en/stable/README/)\n\nThe following command will build cmt and then install it in `~/.local/bin`:\n\n```bash\nstack build \u0026\u0026 stack install\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallhadroncollider%2Fcmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmallhadroncollider%2Fcmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmallhadroncollider%2Fcmt/lists"}