{"id":40609540,"url":"https://github.com/efrecon/pre-commit-hook-branch-check","last_synced_at":"2026-01-21T05:08:11.429Z","repository":{"id":303657346,"uuid":"1015233255","full_name":"efrecon/pre-commit-hook-branch-check","owner":"efrecon","description":"A pre-commit hook to validate branch names","archived":false,"fork":false,"pushed_at":"2025-08-20T14:58:00.000Z","size":7,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-20T16:43:02.977Z","etag":null,"topics":["conventional-branch","pre-commit-hook"],"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/efrecon.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,"zenodo":null}},"created_at":"2025-07-07T07:45:40.000Z","updated_at":"2025-07-08T18:05:16.000Z","dependencies_parsed_at":"2025-07-08T19:24:45.649Z","dependency_job_id":"42047f6a-29bf-489d-926f-5ee32ba0308f","html_url":"https://github.com/efrecon/pre-commit-hook-branch-check","commit_stats":null,"previous_names":["efrecon/pre-commit-hook-branch-check"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/efrecon/pre-commit-hook-branch-check","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efrecon%2Fpre-commit-hook-branch-check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efrecon%2Fpre-commit-hook-branch-check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efrecon%2Fpre-commit-hook-branch-check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efrecon%2Fpre-commit-hook-branch-check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/efrecon","download_url":"https://codeload.github.com/efrecon/pre-commit-hook-branch-check/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efrecon%2Fpre-commit-hook-branch-check/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28627388,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["conventional-branch","pre-commit-hook"],"created_at":"2026-01-21T05:08:10.396Z","updated_at":"2026-01-21T05:08:11.421Z","avatar_url":"https://github.com/efrecon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `pre-commit` hook to check branch names\n\nThis project implements a [pre-commit] [hook] to enforce branch names.\nThe defaults aim at respecting [conventional branches][cb],\nbut options are flexible enough to respect other conventions or set of rules.\n\nThe official [hooks][official] already contain a `no-commit-to-branch` hook,\nbut it expresses an inverted logic and can be cumbersome to [use].\nThis project is more flexible through the use of regular expressions controlling which branch names should be allowed,\nand which branch names should be denied.\n\n  [pre-commit]: https://pre-commit.com/\n  [hook]: ./.pre-commit-hooks.yaml\n  [cb]: https://conventional-branch.github.io/\n  [official]: https://github.com/pre-commit/pre-commit-hooks\n  [use]: https://github.com/pre-commit/pre-commit/issues/1034\n\n## Usage\n\nAdd the following to your `.pre-commit-config.yaml` file.\nThe default is to respect [conventional branches][cb].\nYou might want to check the latest [release] of the repository and change the `rev` key.\n\n```yaml\n  - repo: https://github.com/efrecon/pre-commit-hook-branch-check\n    rev: v0.3.0\n    hooks:\n      - id: branch-check\n```\n\n  [release]: https://github.com/efrecon/pre-commit-branch-check/releases\n\nTo adapt to other conventions, you can use the `--allow` and `--deny` arguments.\nEach argument's value is a regular expression.\n`--allow` and `--deny` can be repeated as many times as possible.\nThe name of a branch **must** match at least one of the regular expressions from the `--allow` arguments.\nThe name of a branch **cannot** match any of the regular expressions from the `--deny` arguments.\n\nFor example, the following would refrain committing to `master` or `main`,\nand would enforce lowercase characters, together with a few separators.\n\n```yaml\n  - repo: https://github.com/efrecon/pre-commit-hook-branch-check\n    rev: v0.3.0\n    hooks:\n      - id: branch-check\n        args:\n          - --deny=^(master|main)$\n          - --allow=^[0-9a-z_./-]+$\n```\n\n## Branch Detection\n\nWhen run from CI systems, `git` might be in detached HEAD state.\nThis happens when running during pull/merge requests.\nThis hook will use known environment variables containing the name of the source branch to cover those cases.\nWhen the variables are not set -- in most cases -- it will first attempt to run the following command:\n\n```bash\ngit symbolic-ref --short HEAD\n```\n\nWhen that command fail, it will revert to using:\n\n```bash\ngit name-rev --name-only HEAD\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefrecon%2Fpre-commit-hook-branch-check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fefrecon%2Fpre-commit-hook-branch-check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefrecon%2Fpre-commit-hook-branch-check/lists"}