{"id":19606285,"url":"https://github.com/dwtechs/gitbranchvalidator","last_synced_at":"2026-04-16T02:31:05.072Z","repository":{"id":56855705,"uuid":"523370178","full_name":"DWTechs/GitBranchValidator","owner":"DWTechs","description":"Git branch name validator for clean workflow and better readability","archived":false,"fork":false,"pushed_at":"2022-08-26T11:58:39.000Z","size":212,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-15T22:35:16.753Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/DWTechs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-10T14:12:31.000Z","updated_at":"2022-08-17T07:43:03.000Z","dependencies_parsed_at":"2022-09-21T13:12:28.074Z","dependency_job_id":null,"html_url":"https://github.com/DWTechs/GitBranchValidator","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DWTechs%2FGitBranchValidator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DWTechs%2FGitBranchValidator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DWTechs%2FGitBranchValidator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DWTechs%2FGitBranchValidator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DWTechs","download_url":"https://codeload.github.com/DWTechs/GitBranchValidator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240894277,"owners_count":19874789,"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":[],"created_at":"2024-11-11T10:04:09.073Z","updated_at":"2026-04-16T02:31:05.035Z","avatar_url":"https://github.com/DWTechs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![License: MIT](https://img.shields.io/npm/l/@dwtechs/gitbranchvalidator.svg?color=brightgreen)](https://opensource.org/licenses/MIT)\n[![npm version](https://badge.fury.io/js/%40dwtechs%2Fgitbranchvalidator.svg)](https://www.npmjs.com/package/@dwtechs/gitbranchvalidator)\n[![last version release date](https://img.shields.io/github/release-date/DWTechs/GitBranchValidator)](https://www.npmjs.com/package/@dwtechs/gitbranchvalidator)\n![Jest:coverage](https://img.shields.io/badge/Jest:coverage-100%25-brightgreen.svg)\n\n- [Synopsis](#synopsis)\n- [Motivation](#motivation)\n- [Installation](#installation)\n  - [npm](#npm)\n  - [Yarn](#yarn)\n  - [Local](#local)\n- [Usage](#usage)\n  - [Command line](#command-line)\n  - [Patterns](#patterns)\n  - [Message](#message)\n  - [Prompt](#prompt)\n  - [Help](#help)\n  - [Workflow integration](#workflow-integration)\n- [Contributors](#contributors)\n- [License](#license)\n- [Stack](#stack)\n- [Dependencies](#dependencies)\n\n## Synopsis\n\n**[GitBranchValidator](https://github.com/DWTechs/GitBranchValidator)** is an open source git branch name validator library.\n\n## Motivation\n\nThe goal of this library is to provide an easy way to check if the current branch name is valid before pushing it to the remote.\n\nIt's a good way to help developers keep their branch names clean on the repository and facilitate the workflow of a project with strict naming rules.\n\nThe default pattern follows the principles described [here](https://dwtechs.github.io/efficient-git/branch/).\n\nYou can also set your own rules using [custom patterns](#patterns).\n\nYou can validate commit messages as well with [GitCommitValidator](https://github.com/DWTechs/GitCommitValidator)\n\n## Installation\n\nThis library is written in Node.js.\nYou must install Node.js and npm in order to run it. \n\n### npm\n\n```bash\n$ npm i @dwtechs/gitbranchvalidator -g\n```\n\n### Yarn\n\n```bash\n$ yarn add @dwtechs/gitbranchvalidator -g\n```\n\n### Locally\n\nAlternatively, if you are planning to use GitBranchValidator within your npm package only or with npx you can install it as a devDependency in your project.\n\n```bash\n$ npm i @dwtechs/gitbranchvalidator --save-dev\n```\n\n```bash\n$ yarn add @dwtechs/gitbranchvalidator --dev\n```\n\n## Usage\n\n**This library is meant to be used in \"pre-commit\", \"commit-msg\" or/and \"pre-push\" Git hook.**\nThus it is not bound to Javasrcipt applications only and can be used by any git repository.\n\nYou can learn more about Git hooks and how ti cutomize them in the [Git Manual](https://git-scm.com/book/en/v2/Customizing-Git-An-Example-Git-Enforced-Policy)\n\nBecause hooks aren’t transferred with a clone of a project, you must distribute these scripts some other way and then have your users copy them to their .git/hooks directory and make them executable. You can distribute these hooks within the project or in a separate project, but Git will not set them up automatically for you.\n\n\n### Command line\n\n```bash\n$ gbvalidator\n```\n\nAlternatively if you did not install GitBranchValidator globally you can use npx.\n\n```bash\n$ npx gbvalidator\n```\n\nOr as an npm script in your package.json.\n\n```json\n{\n  \"scripts\": {\n    \"commit\": \"gbvalidator\"\n  }\n}\n```\n\n### Patterns\n\n- Default : **^(feat|fix|test|doc)\\/[A-Z0-9\\-\\#]{2,25}\\/[a-z0-9_\\-\\.]{3,40}$**\n- Release : **^release\\/v[a-z0-9\\+\\-\\.]{3,25}$**\n\nThe patterns follow the principles described [here](https://dwtechs.github.io/efficient-git/branch/).\n\nYou can use your own custom patterns by adding an optional regexp :\n\n```bash\n$ cd \u003cgit-project\u003e\n$ gbvalidator --patterns \"^(feat|fix)\\\\/([a-z0-9_#-\\\\.\\\\/]){3,50}$\"\n```\n\nYou can use several patterns if needed : \n\n```bash\n$ gbvalidator --patterns \"pattern1\" \"pattern2\" \"pattern3\"\n```\n\nIf one of them is valid, the branch name will be valid.\n\n\n### Message\n\nYou can customize the end of the error message :\n\n```bash\n$ gbvalidator --message \"You can learn more about branch name conventions of this project on https://dwtechs.github.io/efficient-git/branch/\"\n```\n\n### Prompt\n\nIf the branch name is not valid, the process will be blocked by default.\nYou can use the option \"--continue\" to prompt the user instead.\n\n```bash\n$ gbvalidator --continue\n```\n\nIn this case the user will be prompted about the invalid branch. He will be able to keep going if he choose so.\n\n_Git hooks are not run in an interactive environment. So this option will fail if used in a Git hook._\n\n### Help\n\nYou can access the documentation by passing the \"help\" parameter :\n\n```bash\n$ gbvalidator --help\n```\n\n### Workflow integration\n\nValidate branch name on pre-push hook by adding the following code in the .git/hooks/pre-push file : \n\n```bash\ngbvalidator\n```\n\nOr with tools like Husky In the package.json file :\n\n```json\n{\n  \"husky\": {\n    \"hooks\": {\n      \"pre-push\": \"gbvalidator\"\n    }\n  }\n}\n```\nYou can do it with any other tool, or work on Git hooks directly.\n\n\nYou can use GitCommitValidator in the \"commit-msg\" hook as well : \n\n```bash\ngbvalidator \u0026\u0026 gcvalidator -src \"$1\"\n```\n\n\nYou can find git hooks examples in the ./hooks/ folder.\nTo install them just paste them in the .git/hooks/ folder of your repositories.\n\n\n\n## options\n\n| Option       | Alias |  Type   |                                                                                                          description |\n| :----------  | :---: | :-----: | -------------------------------------------------------------------------------------------------------------------: |\n| --patterns   |  -p   | string  |                                                                   Use a custom regex. You can send multiple patterns |\n| --message    |  -m   | string  |                                                                 Add a custom message at the end of the error message |\n| --continue   |  -c   | string  | Prompt the user if the branch name is not valid, instead of stopping the process. Does not work if used in Git hooks |\n| --help       |  -h   | boolean |                                                                                            Learn about library usage |\n\n## Contributors\n\nGitBranchValidator is still in development and I would be glad to get all the help you can provide for this project.\nTo contribute please read **[contributor.md](https://github.com/DWTechs/GitBranchValidator/blob/master/contributor.md)** for detailed installation guide.\n\n## License\n\n**[MIT](https://github.com/DWTechs/GitBranchValidator/blob/master/LICENSE)**\n\n## Stack\n\n| Purpose         |                Choice                |                                                 Motivation |\n| :-------------- | :----------------------------------: | ---------------------------------------------------------: |\n| repository      |    [Github](https://github.com/)     | hosting for software development version control using Git |\n| package manager | [npm](https://www.npmjs.com/get-npm) |                            default node.js package manager |\n| unit testing    |      [Jest](https://jestjs.io/)      |              delightful testing with a focus on simplicity |\n\n## Dependencies\n\n| Name | version |\n| :--- | :----- |\n| @dwtechs/checkhard | 2.19.0 |\n| command-line-args  | 5.2.1 |\n| command-line-usage | 6.1.3 |\n| current-git-branch | 1.1.0 |\n| prompts            | 2.4.2 |","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwtechs%2Fgitbranchvalidator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdwtechs%2Fgitbranchvalidator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwtechs%2Fgitbranchvalidator/lists"}