{"id":17316912,"url":"https://github.com/real-yfprojects/check-pre-commit-config","last_synced_at":"2026-02-09T22:02:36.682Z","repository":{"id":167346769,"uuid":"642950532","full_name":"real-yfprojects/check-pre-commit-config","owner":"real-yfprojects","description":"Ensure correct `frozen: x.x.x` comments in `.pre-commit-config.yaml`.","archived":false,"fork":false,"pushed_at":"2024-03-04T16:52:15.000Z","size":171,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-12T16:17:59.078Z","etag":null,"topics":["comments","frozen","git","linter","pre-commit","pre-commit-config","python","refactoring","revisions","style"],"latest_commit_sha":null,"homepage":"","language":"Python","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/real-yfprojects.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}},"created_at":"2023-05-19T18:13:01.000Z","updated_at":"2023-05-27T17:53:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"5a109af8-7c09-47e7-9844-7857d33e497d","html_url":"https://github.com/real-yfprojects/check-pre-commit-config","commit_stats":null,"previous_names":["real-yfprojects/check-pre-commit-config-frozen","real-yfprojects/check-pre-commit-config"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/real-yfprojects%2Fcheck-pre-commit-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/real-yfprojects%2Fcheck-pre-commit-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/real-yfprojects%2Fcheck-pre-commit-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/real-yfprojects%2Fcheck-pre-commit-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/real-yfprojects","download_url":"https://codeload.github.com/real-yfprojects/check-pre-commit-config/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247471279,"owners_count":20944153,"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":["comments","frozen","git","linter","pre-commit","pre-commit-config","python","refactoring","revisions","style"],"created_at":"2024-10-15T13:14:46.126Z","updated_at":"2026-02-09T22:02:35.832Z","avatar_url":"https://github.com/real-yfprojects.png","language":"Python","readme":"# check-pre-commit-config\n\n[![GitHub release](https://img.shields.io/github/v/release/real-yfprojects/check-pre-commit-config?include_prereleases)](https://github.com/real-yfprojects/check-pre-commit-config/releases)\n[![Github License](https://img.shields.io/github/license/real-yfprojects/check-pre-commit-config-frozen?color=bd0000)](https://github.com/real-yfprojects/check-pre-commit-config-frozen/blob/master/LICENSE)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nEnforce rules regarding frozen revisions in `.pre-commit-config.yaml`.\n\n\u003c!-- prettier-ignore-start --\u003e\n```yaml\n  # Enforce frozen revisions in `.pre-commit-config.yaml`\n  - repo: https://github.com/real-yfprojects/check-pre-commit-config\n    rev: v1.0.0-alpha3\n    hooks:\n      - id: check-frozen\n```\n\u003c!-- prettier-ignore-end --\u003e\n\nWe advise to put this hook before any yaml formatters (like prettier) that you have configured as well.\n\n## Features\n\nThis pre-commit hook ensures rules regarding the use of frozen revisions and\nregarding annotating them with a `frozen: xxx` comment.\nSome rules can be fixed automatically by this hook.\nThe following rules are supported and enabled by default with the exception\nof the `u` rule. Refer to the `Args` section for information on how to customize\nthe behaviour of the hook. Some rules are more expensive to process since they require downloading git information for the repositories specified in `.pre-commit-config.yaml`. Conveniently this hook won't run those checks if the corresponding rules are disabled.\n\nRevisions are considered frozen when a _hex object name_ is used. That is a hash of a commit is used as a revision. Git accepts passing only the starting letters of a _hex object name_ as long as the passed _abbreviated_ hash is unambiguous. Such abbreviated hashes are considered to be frozen revisions as well.\n\n#### Rules\n\n| Code | Fixable            | Enforces that...                                                                                                                   |\n| ---- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------- |\n| `y`  | ❌ | the files can be processed by the yaml parser without error.                                                                       |\n| `c`  | ❌ | the files contain the pre-commit configuration elements the other checks will run on.                                              |\n| `f`  | ✅ | all revisions are frozen.                                                                                                          |\n| `u`  | ✅ | no revisions are frozen.                                                                                                           |\n| `a`  | ❌ | no revision is used that could be an abbreviated hash (hex object name).                                                           |\n| `m`  | ✅ | there is a comment of the form `frozen: xxx` for each frozen revision.                                                             |\n| `e`  | ✅ | unfrozen revisions do not have a comment of the form `frozen: xxx`                                                                 |\n| `t`  | ✅ | the tag mentioned in the comment of the form `frozen: xxx` matches the hash used as a revision. (only applies for frozen comments) |\n\nThe rules `u` and `f` cannot be enabled together.\n\n## Alternatives\n\nYou can also implement rules `f`, `u`, `m`, `e` with a more lightweight and faster pygrep hook.\nThat is a simple check against a regular expression:\n\n\u003c!-- prettier-ignore-start --\u003e\n```yaml\n  - repo: local\n    hooks:\n      - id: rev-frozen\n        name: revs must be frozen\n        entry: \"\\\\brev: (?!['\\\"]?[a-f0-9]{40})\"\n        language: pygrep\n        files: '\\.pre-commit-config.yaml'\n      - id: rev-frozen-comment\n        name: frozen revs must have a corresponding comment\n        entry: \"\\\\brev: (['\\\"]?)[a-f0-9]{40}\\\\1(?!\\\\s*# frozen: \\\\S+)\"\n        language: pygrep\n        files: '\\.pre-commit-config.yaml'\n      - id: rev-unfrozen\n        name: revs may not be frozen\n        entry: \"\\\\brev: ['\\\"]?[a-f0-9]{40}\"\n        language: pygrep\n        files: '\\.pre-commit-config.yaml'\n      - id: rev-unfrozen-comment\n        name: unfrozen revs may not have a contradicting comment\n        entry: \"\\\\brev: (?!(['\\\"]?)[a-f0-9]{40}\\\\1).*\\\\s*# frozen:\"\n        language: pygrep\n        files: '\\.pre-commit-config.yaml'\n```\n\u003c!-- prettier-ignore-end --\u003e\n\n## Versioning\n\nIn adherence to [semver](https://semver.org/) the following rules determine compatibility between different versions of this hook.\n\n| Version | Increased when...                                                                                                                                                                                                                                          |\n| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| MAJOR   | the behaviour or the code of a rule is changed, \u003c/br\u003e a rule is removed, \u003cbr\u003e the default configuration of this hook is changed, \u003cbr\u003e commandline arguments are renamed/repurposed/removed, \u003c/br\u003e compatibility is majorly broken in some other major way. |\n| MINOR   | rules are added, \u003c/br\u003e new commandline options are introduced.                                                                                                                                                                                             |\n| PATCH   | All fixes/changes that aren't handled above.                                                                                                                                                                                                               |\n\n## Args\n\nWhen passing a list of rules for an argument the codes of the rules are expected without a delimiter. E.g.: `ycfamt` which would be equivalent to passing the `--strict` flag.\n\n```\nusage: check-pre-commit-config-frozen [-h] [--rules RULES] [--disable DISABLE] [--strict] [--fix FIX | --fix-all] [--print] [--quiet] [--format FORMAT] [--no-colour] [--verbose] file [file ...]\n\npositional arguments:\n  file               The files to enforce the rules on.\n\noptional arguments:\n  -h, --help         show this help message and exit\n  --rules RULES      Enable rules.\n  --disable DISABLE  Disable rules overriding any other cmd argument. When passed alone, it will enable all rules not specified.\n  --strict           Enable the rules `ycfamt`.\n  --fix FIX          Select rules to automatically fix.\n  --fix-all          Enable all fixes available.\n  --print            Print fixed file contents to stdout instead of writing them back into the files.\n  --quiet            Don't output anything\n  --format FORMAT    The output format for complains. Use python string formatting. Rich markup is also supported.\n  --no-colour        Disable colourful output\n  --verbose, -v      Increase level of debug logs displayed.\n```\n\nBy default `--strict --fix-all` is passed to the underlying script.\n\n### Examples\n\nYou can customize the hooks behaviour by overriding which command line arguments\nare passed to the underlying script when the hook is run. The following configuration can be used to prevent frozen revisions from being committed:\n\n\u003c!-- prettier-ignore-start --\u003e\n```yaml\n  # Prevent use of frozen revisions in `.pre-commit-config.yaml`\n  - repo: https://github.com/real-yfprojects/check-pre-commit-config\n    rev: v1.0.0-alpha3\n    hooks:\n      - id: check-frozen\n        args:\n          - \"--rules\"\n          - \"ycue\"\n          - \"--fix-all\"\n```\n\u003c!-- prettier-ignore-end --\u003e\n\nIf you just want to make sure that comments match revisions and that no abbreviated hashes are used the following configuration will be suited:\n\n\u003c!-- prettier-ignore-start --\u003e\n```yaml\n  # Check use of `frozen: xxx` comments in `.pre-commit-config.yaml`\n  - repo: https://github.com/real-yfprojects/check-pre-commit-config\n    rev: v1.0.0-alpha3\n    hooks:\n      - id: check-frozen\n        args:\n          - \"--rules\"\n          - \"ycamet\"\n          - \"--fix-all\"\n```\n\u003c!-- prettier-ignore-end --\u003e\n\n## Contributing\n\nThis project is developed in an open-source, community-driven way, as a\nvoluntary effort in the authors’ free time.\n\nAll contributions are greatly appreciated… pull requests are welcome,\nand so are bug reports and suggestions for improvement.\nThe value of contributions about simplifying or otherwise improving the implementation of existing features, extending and enhancing the documentation are often underestimated or forgotten. Last but not least their are some tasks listed below that I haven't worked on yet listed below.\n\n### TODO\n\n-   [ ] Complete tests, achieve high test coverage\n-   [ ] Automation\n    -   [ ] pre-commit.ci\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freal-yfprojects%2Fcheck-pre-commit-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freal-yfprojects%2Fcheck-pre-commit-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freal-yfprojects%2Fcheck-pre-commit-config/lists"}