{"id":13631731,"url":"https://github.com/m1foley/fit-commit","last_synced_at":"2025-04-08T11:08:08.400Z","repository":{"id":33591445,"uuid":"37243448","full_name":"m1foley/fit-commit","owner":"m1foley","description":"A Git hook to validate your commit messages based on community standards.","archived":false,"fork":false,"pushed_at":"2023-06-08T22:11:02.000Z","size":132,"stargazers_count":471,"open_issues_count":3,"forks_count":23,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-01T09:23:08.843Z","etag":null,"topics":["commit-message","git","git-addons","git-hooks","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/m1foley.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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}},"created_at":"2015-06-11T06:29:45.000Z","updated_at":"2025-02-08T03:18:30.000Z","dependencies_parsed_at":"2024-01-22T01:08:39.949Z","dependency_job_id":"6b7c2506-ffea-4a8e-b34e-719aeb5456c6","html_url":"https://github.com/m1foley/fit-commit","commit_stats":{"total_commits":137,"total_committers":10,"mean_commits":13.7,"dds":"0.17518248175182483","last_synced_commit":"32fd3bf42b9485720b487bbe8380cf9a239394c9"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1foley%2Ffit-commit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1foley%2Ffit-commit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1foley%2Ffit-commit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1foley%2Ffit-commit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m1foley","download_url":"https://codeload.github.com/m1foley/fit-commit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247829491,"owners_count":21002995,"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","git","git-addons","git-hooks","ruby"],"created_at":"2024-08-01T22:02:36.121Z","updated_at":"2025-04-08T11:08:08.371Z","avatar_url":"https://github.com/m1foley.png","language":"Ruby","readme":"# Fit Commit\n\nA Git hook to validate your commit messages based on [community standards](#who-decided-these-rules).\n\n## Example\n\n```\n$ git commit\nAdding a cool feature\nfoobar foobar foobar,\nfoobar foobar foobar foobar foobar foobar foobar foobar foobar foobar foobar\n\n1: Error: Message must use imperative present tense.\n2: Error: Second line must be blank.\n3: Error: Lines should be \u003c= 72 chars. (76)\n\nCommit anyway? [y/n/e] ▊\n```\n\n## Prerequisites\n\n* Ruby \u003e= 1.9 (OS X users already have this installed)\n\n## Installation\n\nInstall the gem:\n\n    $ gem install fit-commit\n\nInstall the hook in your Git repo:\n\n    $ fit-commit install\n\nThis creates a `.git/hooks/commit-msg` script which will automatically check your Git commit messages.\n\n## Validations\n\n* **Line Length**: All lines must be \u003c= 72 chars (URLs excluded). First line should be \u003c= 50 chars. Second line must be blank.\n* **Tense**: Message must use imperative present tense: \"Fix bug\" and not \"Fixed bug\" or \"Fixes bug.\"\n* **Subject Period**: Do not end your subject line with a period.\n* **Capitalize Subject**: Begin all subject lines with a capital letter.\n* **Frat House**: No offensive content.\n* **WIP**: Do not commit WIPs to shared branches (disabled by default)\n\n## Configuration\n\nSettings are read from these files in increasing precedence: `/etc/fit_commit.yml`, `$HOME/.fit_commit.yml`, `config/fit_commit.yml`, `./.fit_commit.yml`.\n\nThese are the default settings that can be overridden:\n\n```yaml\n---\nValidators/LineLength:\n  Enabled: true\n  MaxLineLength: 72\n  SubjectWarnLength: 50\n  AllowLongUrls: true\nValidators/Tense:\n  Enabled: true\nValidators/SubjectPeriod:\n  Enabled: true\nValidators/CapitalizeSubject:\n  Enabled: true\n  WarnOnWiplikes: true\nValidators/Frathouse:\n  Enabled: true\nValidators/Wip:\n  Enabled: false\n```\n\nThe `Enabled` property accepts multiple formats:\n\n```yaml\n# true/false to enable/disable the validation (branch agnostic)\nValidators/Foo:\n  Enabled: false\n# Array of String or Regex matching each branch it's enabled on\nValidators/Bar:\n  Enabled:\n    - main\n    - !ruby/regexp /\\Afoo.+bar/\n```\n\n## Adding Custom Validators\n\nCreate your custom validator as a `FitCommit::Validators::Base` subclass:\n\n```ruby\nmodule FitCommit\n  module Validators\n    class MyCustomValidator \u003c Base\n      def validate_line(lineno, text)\n        if text =~ /sneak peak/i\n          add_error(lineno, \"I think you mean 'sneak peek'.\")\n        end\n      end\n    end\n  end\nend\n\n# A validator can also validate the commit message as a whole:\nmodule FitCommit\n  module Validators\n    class MyCustomValidator \u003c Base\n      def validate(lines)\n        if lines.none? { |line| line.text =~ /#\\d+/ }\n          add_warning(lines.last.lineno, \"Related issue not referenced.\")\n        end\n      end\n    end\n  end\nend\n```\n\n`Require` the file and enable the validator in your config:\n\n```yaml\nFitCommit:\n  Require:\n    - somedir/my_custom_validator.rb\nValidators/MyCustomValidator:\n  Enabled: true\n```\n\nYou can also publish your validator as a gem, and require it that way:\n\n```yaml\nFitCommit:\n  Require:\n    - my-custom-validator-gem\nValidators/MyCustomValidator:\n  Enabled: true\n```\n\nIf others might find your validator useful, submit it as a Pull Request. If it's not useful for everyone, it can be disabled by default.\n\n## FAQ\n\n### Can Fit Commit run in all my repos without having to install it each time?\nFirst set your global Git template directory:\n\n```\n$ git config --global init.templatedir '~/.git_template'\n$ mkdir -p ~/.git_template/hooks\n```\n\nNow you can copy the hooks you want installed in new repos by default:\n\n```\n# From a repo where Fit Commit is already installed\n$ cp .git/hooks/commit-msg ~/.git_template/hooks/commit-msg\n```\n\nTo copy your default hooks into existing repos:\n\n```\n$ git init\n```\n\n### How can I run this standalone, like part of a CI process?\n\nFit Commit can be run outside of a Git hook context with a simple shell script:\n\n```sh\n$ export GIT_BRANCH_NAME=branch_name\n$ export COMMIT_MESSAGE_PATH=path/to/message\n# Using Bundler\n$ bundle exec ruby -e 'require \"fit_commit\"; FitCommit.run'\n# Not using Bundler\n$ rbenv exec ruby -rrubygems -e 'require \"fit_commit\"; FitCommit.run'\n```\n\nIt exits with an error code if any errors are present, which will fail a build if it's part of a CI run.\n\n### Who decided these rules?\nFit Commit aims to enforce *community standards*. The two influential guides are:\n\n- [Tim Pope's blog](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)\n- [The official Git documentation](http://git.kernel.org/cgit/git/git.git/tree/Documentation/SubmittingPatches?id=HEAD)\n\nThe Git community has largely (but not completely) coalesced around these standards. [Chris Beams](http://chris.beams.io/posts/git-commit/) and the [Pro Git book](https://git-scm.com/book) also provide good summaries on why we have them.\n\n### How can I improve Fit Commit?\nFit Commit aims to be useful to everyone. If you can suggest an improvement to make it useful to more people, please open a GitHub Issue or Pull Request. See [CONTRIBUTING.md](CONTRIBUTING.md) for more info.\n\n\n## Credits\n\nAuthor: [Mike Foley](https://github.com/m1foley)\n\nInspiration taken from: [Tim Pope](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), [Jason Fox](https://gist.github.com/jasonrobertfox/8057124), [Addam Hardy](http://addamhardy.com/blog/2013/06/05/good-commit-messages-and-enforcing-them-with-git-hooks/), [pre-commit](https://github.com/jish/pre-commit)\n\nSimilar projects:\n- [gitlint](https://github.com/jorisroovers/gitlint) (written in Python)\n- [fit-commit-js](https://www.npmjs.com/package/fit-commit-js) (Node.js package)\n","funding_links":[],"categories":["Ruby","ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1foley%2Ffit-commit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm1foley%2Ffit-commit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1foley%2Ffit-commit/lists"}