{"id":17354294,"url":"https://github.com/aentwist/pre-commit-mirrors-commitlint","last_synced_at":"2026-03-19T00:59:34.065Z","repository":{"id":206092702,"uuid":"715817511","full_name":"aentwist/pre-commit-mirrors-commitlint","owner":"aentwist","description":"⚠️📓 pre-commit hooks for commitlint","archived":false,"fork":false,"pushed_at":"2025-03-08T08:27:19.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-08T09:29:08.017Z","etag":null,"topics":["ci","commitlint","pre-commit","pre-commit-hooks"],"latest_commit_sha":null,"homepage":"","language":null,"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/aentwist.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":"2023-11-07T22:25:32.000Z","updated_at":"2025-03-08T08:27:23.000Z","dependencies_parsed_at":"2023-11-12T09:24:17.175Z","dependency_job_id":"361aafec-ad65-4626-b67a-3a951c924182","html_url":"https://github.com/aentwist/pre-commit-mirrors-commitlint","commit_stats":null,"previous_names":["aentwist/pre-commit-mirrors-commitlint"],"tags_count":127,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aentwist%2Fpre-commit-mirrors-commitlint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aentwist%2Fpre-commit-mirrors-commitlint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aentwist%2Fpre-commit-mirrors-commitlint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aentwist%2Fpre-commit-mirrors-commitlint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aentwist","download_url":"https://codeload.github.com/aentwist/pre-commit-mirrors-commitlint/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245851799,"owners_count":20682934,"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":["ci","commitlint","pre-commit","pre-commit-hooks"],"created_at":"2024-10-15T17:19:36.398Z","updated_at":"2026-01-07T07:09:42.115Z","avatar_url":"https://github.com/aentwist.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# commitlint pre-commit hooks\n\n[pre-commit](https://github.com/pre-commit/pre-commit) hooks for [commitlint](https://github.com/conventional-changelog/commitlint)\n\n## Using commitlint with pre-commit\n\n### Derivation\n\nAdd this to your `.pre-commit-config.yaml`:\n\n```yaml\n- repo: https://github.com/aentwist/pre-commit-mirrors-commitlint\n  rev: \"\"  # Use the sha / tag you want to point at\n  hooks:\n    - id: commitlint\n```\n\nSince this is a commit-msg hook (not a typical, pre-commit hook), it needs additional configuration. By default, pre-commit runs `hooks` in all `stages` but only installs one stage, pre-commit. Adding a commit-msg hook we also need to install the commit-msg stage, but then since hooks are run in all stages by default, other hooks in the file will run multiple times. To prevent this, we can flip this logic: run hooks in specific stages and install hooks for all stages (or just the stages we need).\n\n```yaml\n# Install hooks for all stages instead of just for the pre-commit stage.\ndefault_install_hook_types: [pre-commit, commit-msg]\n# Limit hooks to running in the pre-commit stage unless specified otherwise.\ndefault_stages: [pre-commit]\nrepos:\n  - repo: https://github.com/aentwist/pre-commit-mirrors-commitlint\n    rev: \"\"  # Use the sha / tag you want to point at\n    hooks:\n      - id: commitlint\n        # commitlint is a commit-msg hook\n        stages: [commit-msg]\n```\n\nSee [Configuring hooks to run at certain stages](https://pre-commit.com/#confining-hooks-to-run-at-certain-stages).\n\nFinally, when using plugins with commitlint you'll need to declare them under `additional_dependencies`. Since this overrides the `additional_dependencies` in this hook, you will also need to redeclare the `commitlint` dependency. For example:\n\n```yaml\n- repo: https://github.com/aentwist/pre-commit-mirrors-commitlint\n  rev: v18.2.0\n  hooks:\n    - id: commitlint\n      additional_dependencies:\n        - commitlint@18.2.0\n        - \"@commitlint/config-conventional@18.1.0\"\n```\n\nCombining these ideas together, we have a complete example:\n\n### Result\n\n```yaml\ndefault_install_hook_types: [pre-commit, commit-msg]\ndefault_stages: [pre-commit]\nrepos:\n  - repo: https://github.com/aentwist/pre-commit-mirrors-commitlint\n    rev: v18.2.0\n    hooks:\n      - id: commitlint\n        stages: [commit-msg]\n        additional_dependencies:\n          - commitlint@18.2.0\n          - \"@commitlint/config-conventional@18.1.0\"\n```\n\n## CI\n\nThe main hook checks a commit message at the time it is made. To run on a range of commits after they have been made, we need a separate hook.\n\nThis hook is `commitlint-all`. It runs commitlint on all commits. Note that it cannot run only on branch commits due to pre-commit limitations. To explore other options see [the discussion](https://github.com/aentwist/pre-commit-mirrors-commitlint/discussions/1).\n\n### Derivation\n\nAdding the `commitlint-all` hook, we have\n\n```yaml\ndefault_install_hook_types: [pre-commit, commit-msg]\ndefault_stages: [pre-commit]\nrepos:\n  - repo: https://github.com/aentwist/pre-commit-mirrors-commitlint\n    rev: v18.2.0\n    hooks:\n      - id: commitlint\n        stages: [commit-msg]\n        additional_dependencies:\n          - commitlint@18.2.0\n          - \"@commitlint/config-conventional@18.1.0\"\n      - id: commitlint-all\n        stages: [manual]\n        additional_dependencies:\n          - commitlint@18.2.0\n          - \"@commitlint/config-conventional@18.1.0\"\n```\n\nWe can [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself) this out with a [YAML anchor](https://support.atlassian.com/bitbucket-cloud/docs/yaml-anchors/):\n\n### Result\n\n```yaml\ndefault_install_hook_types: [pre-commit, commit-msg]\ndefault_stages: [pre-commit]\nrepos:\n  - repo: https://github.com/aentwist/pre-commit-mirrors-commitlint\n    rev: v18.2.0\n    hooks:\n      - id: commitlint\n        stages: [commit-msg]\n        additional_dependencies: \u0026commitlint-additional-dependencies\n          - commitlint@18.2.0\n          - \"@commitlint/config-conventional@18.1.0\"\n      - id: commitlint-all\n        stages: [manual]\n        additional_dependencies: *commitlint-additional-dependencies\n```\n\nRun the hook manually with `pre-commit run --hook-stage=manual --files .pre-commit-config.yaml commitlint-all`.\n\nNote that we need to both specify the hook stage, and feed pre-commit some files so it knows it needs to run the hook. Using `--all-files` runs the hook once per file; instead, specify only one file to run the hook once. Choose the one file we know exists: the pre-commit config.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faentwist%2Fpre-commit-mirrors-commitlint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faentwist%2Fpre-commit-mirrors-commitlint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faentwist%2Fpre-commit-mirrors-commitlint/lists"}