{"id":13413500,"url":"https://github.com/antham/gommit","last_synced_at":"2025-04-05T21:06:58.064Z","repository":{"id":37548400,"uuid":"66933508","full_name":"antham/gommit","owner":"antham","description":"Enforce git message commit consistency","archived":false,"fork":false,"pushed_at":"2025-03-27T10:12:05.000Z","size":499,"stargazers_count":114,"open_issues_count":1,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T20:04:00.617Z","etag":null,"topics":["commit-message","commits","consistency","git"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antham.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-30T11:10:11.000Z","updated_at":"2025-03-27T10:12:07.000Z","dependencies_parsed_at":"2023-11-07T10:27:40.935Z","dependency_job_id":"87beca0f-b352-47de-9257-094b710eb0ce","html_url":"https://github.com/antham/gommit","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antham%2Fgommit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antham%2Fgommit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antham%2Fgommit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antham%2Fgommit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antham","download_url":"https://codeload.github.com/antham/gommit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399873,"owners_count":20932876,"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":["commit-message","commits","consistency","git"],"created_at":"2024-07-30T20:01:41.763Z","updated_at":"2025-04-05T21:06:58.034Z","avatar_url":"https://github.com/antham.png","language":"Go","readme":"# Gommit [![codecov](https://codecov.io/gh/antham/gommit/branch/master/graph/badge.svg)](https://codecov.io/gh/antham/gommit) [![Go Report Card](https://goreportcard.com/badge/github.com/antham/gommit)](https://goreportcard.com/report/github.com/antham/gommit) [![GitHub tag](https://img.shields.io/github/tag/antham/gommit.svg)]()\n\nGommit analyze commits messages to ensure they follow defined pattern.\n\n[![asciicast](https://asciinema.org/a/0j12qm7yay1kku7o3vrs67pv2.png)](https://asciinema.org/a/0j12qm7yay1kku7o3vrs67pv2)\n\n## Summary\n\n- [Setup](#setup)\n- [Usage](#usage)\n- [Practical Usage](#practical-usage)\n- [Third Part Libraries](#third-part-libraries)\n\n## Setup\n\nDownload from release page according to your architecture gommit binary : https://github.com/antham/gommit/releases\n\n### Define a file .gommit.toml\n\nCreate a file `.gommit.toml` at the root of your project, for instance :\n\n```toml\n[config]\nexclude-merge-commits=true\ncheck-summary-length=true\nsummary-length=50\n\n[matchers]\nall=\"(?:ref|feat|test|fix|style)\\\\(.*?\\\\) : .*?\\n(?:\\n?(?:\\\\* |  ).*?\\n)*\"\n\n[examples]\na_simple_commit=\"\"\"\n[feat|test|ref|fix|style](module) : A commit message\n\"\"\"\nan_extended_commit=\"\"\"\n[feat|test|ref|fix|style](module) : A commit message\n\n* first line\n* second line\n* and so on...\n\"\"\"\n```\n\n#### Config\n\n- `exclude-merge-commits` : if set to true, will not check commit message for merge commit\n- `check-summary-length` : if set to true, check commit summary length, default is 50 characters\n- `summary-length` : you can override the default value summary length, which is 50 characters, this config is used only if check-summary-length is true\n\n#### Matchers\n\nYou can define as many matchers you want using regexp, naming is up to you, they will all be compared against a commit message till one match. Regexps used support comments, possessive match, positive lookahead, negative lookahead, positive lookbehind, negative lookbehind, back reference, named back referenc and conditionals.\n\n#### Examples\n\nProvided to help user to understand where is the problem, like matchers you can define as many examples as you want, they all will be displayed to the user if an error occured.\n\nIf you defined for instance :\n\n```\na_simple_commit=\"\"\"\n[feat|test|ref|fix|style](module) : A commit message\n\"\"\"\n```\n\nthis example will be displayed to the user like that :\n\n```\nA simple commit :\n\n[feat|test|ref|fix|style](module) : A commit message\n```\n\nkey is used as a title, underscore are replaced with withespaces.\n\n## Usage\n\n```bash\nEnsure your commit messages are consistent\n\nUsage:\n  gommit [command]\n\nAvailable Commands:\n  check       Check ensure a message follows defined patterns\n  version     App version\n\nFlags:\n      --config string    (default \".gommit.toml\")\n  -h, --help            help for gommit\n\nUse \"gommit [command] --help\" for more information about a command.\n```\n\n### check\n\n```bash\nCheck ensure a message follows defined patterns\n\nUsage:\n  gommit check [flags]\n  gommit check [command]\n\nAvailable Commands:\n  commit      Check commit message\n  message     Check message\n  range       Check messages in commit range\n\nFlags:\n  -h, --help   help for check\n\nGlobal Flags:\n      --config string    (default \".gommit.toml\")\n\nUse \"gommit check [command] --help\" for more information about a command.\n\n\nYou need to provide two commit references to run matching for instance :\n```\n\n#### check commit\n\n```bash\nCheck commit message\n\nUsage:\n  gommit check commit [id] [\u0026path] [flags]\n\nFlags:\n  -h, --help   help for commit\n\nGlobal Flags:\n      --config string    (default \".gommit.toml\")\n```\n\nCheck one comit from its commit ID, doesn't support short ID currently :\n\n`gommit check commit aeb603ba83614fae682337bdce9ee1bad1da6d6e`\n\n#### check message\n\n```bash\nCheck message\n\nUsage:\n  gommit check message [message] [flags]\n\nFlags:\n  -h, --help   help for message\n\nGlobal Flags:\n      --config string    (default \".gommit.toml\")\n```\n\nCheck a message, useful for script for instance when you want to use it with git hooks :\n\n`gommit check message \"Hello\"`\n\n#### check range\n\n```bash\nCheck messages in range\n\nUsage:\n  gommit check range [revisionfrom] [revisionTo] [\u0026path] [flags]\n\nFlags:\n  -h, --help   help for range\n\nGlobal Flags:\n      --config string    (default \".gommit.toml\")\n```\n\nCheck a commit range, useful if you want to use it with a CI to ensure all commits in branch are following your conventions :\n\n- with relative references : `gommit check range master~2^ master`\n- with absolute references : `gommit check range dev test`\n- with commit ids (doesn't support short ID currently) : `gommit check range 7bbb37ade3ff36e362d7e20bf34a1325a15b 09f25db7971c100a8c0cfc2b22ab7f872ff0c18d`\n\n## Practical usage\n\nIf your system isn't described here and you find a way to have gommit working on it, please improve this documentation by doing a PR for the next who would like to do the same.\n\n### Git hook\n\nIt's possible to use gommit to validate each commit when you are creating them. To do so, you need to use the `commit-msg` hook, you can replace default script with this one :\n\n```\n#!/bin/sh\n\ngommit check message \"$(cat \"$1\")\";\n```\n\n### Travis\n\nIn travis, all history isn't cloned, default depth is 50 commits, you can change it : https://docs.travis-ci.com/user/customizing-the-build#Git-Clone-Depth.\n\nFirst, we download the binary from the release page according to the version we want and we add in `.travis.yml` :\n\n```yaml\nbefore_install:\n  - wget -O /tmp/gommit https://github.com/antham/gommit/releases/download/v2.0.0/gommit_linux_386 \u0026\u0026 chmod 777 /tmp/gommit\n```\n\nWe can add a perl script in our repository to analyze the commit range against master for instance (master reference needs to be part of cloned history):\n\n```perl\n#!/bin/perl\n\n`git ls-remote origin master` =~ /([a-f0-9]{40})/;\n\nmy $refHead = `git rev-parse HEAD`;\nmy $refTail = $1;\n\nchomp($refHead);\nchomp($refTail);\n\nif ($refHead eq $refTail) {\n    exit 0;\n}\n\nsystem \"gommit check range $refTail $refHead\";\n\nif ($? \u003e 0) {\n    exit 1;\n}\n```\n\nAnd finally in `.travis.yml`, make it crashs when an error occured :\n\n```yaml\nscript: perl test-branch-commit-messages-in-travis.pl\n```\n\n### CircleCI\n\nIn CircleCI (2.0), there is an environment variable that describe current branch : `CIRCLE_BRANCH` (https://circleci.com/docs/2.0/env-vars/#circleci-environment-variable-descriptions).\n\nFirst, we download the binary from the release page according to the version we want and we add in `.circleci/config.yml` :\n\n```yaml\n- run:\n    name: Get gommit binary\n    command: |\n      mkdir /home/circleci/bin\n      wget -O ~/bin/gommit https://github.com/antham/gommit/releases/download/v2.0.0/gommit_linux_386 \u0026\u0026 chmod 777 ~/bin/gommit\n```\n\nAnd we can run gommit against master for instance :\n\n```yaml\n- run:\n    name: Run gommit\n    command: |\n      if [ $CIRCLE_BRANCH != 'master' ]; then ~/bin/gommit check range $(git rev-parse origin/master) $CIRCLE_BRANCH ; fi\n```\n\n## Third Part Libraries\n\n### Nodejs\n\n- [gommitjs](https://github.com/dschnare/gommitjs) : A Nodejs wrapper for gommit\n","funding_links":[],"categories":["Microsoft Office","Miscellaneous","其他","杂项","其他杂项","Uncategorized","Go"],"sub_categories":["Uncategorized","交流","未分类的","暂未分类","Strings","暂未分类这些库被放在这里是因为其他类别似乎都不适合。","Advanced Console UIs"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantham%2Fgommit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantham%2Fgommit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantham%2Fgommit/lists"}