{"id":21294185,"url":"https://github.com/dwtechs/gitcommitvalidator","last_synced_at":"2025-03-15T17:11:23.464Z","repository":{"id":116966062,"uuid":"525681254","full_name":"DWTechs/GitCommitValidator","owner":"DWTechs","description":"Git commit message validator for clean workflow and better readability","archived":false,"fork":false,"pushed_at":"2022-11-20T11:04:32.000Z","size":107,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-03-24T16:03:29.080Z","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-17T07:17:20.000Z","updated_at":"2022-08-20T19:20:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"b3c4a0ae-4161-4d92-83f1-3ff3ee78e6af","html_url":"https://github.com/DWTechs/GitCommitValidator","commit_stats":{"total_commits":16,"total_committers":3,"mean_commits":5.333333333333333,"dds":0.5625,"last_synced_commit":"5d8970244f1ea72f941db7bcb2e04ed881a0daec"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DWTechs%2FGitCommitValidator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DWTechs%2FGitCommitValidator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DWTechs%2FGitCommitValidator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DWTechs%2FGitCommitValidator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DWTechs","download_url":"https://codeload.github.com/DWTechs/GitCommitValidator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243762270,"owners_count":20343979,"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-21T13:58:06.723Z","updated_at":"2025-03-15T17:11:23.441Z","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/gitcommitvalidator.svg?color=brightgreen)](https://opensource.org/licenses/MIT)\n[![npm version](https://badge.fury.io/js/%40dwtechs%2Fgitcommitvalidator.svg)](https://www.npmjs.com/package/@dwtechs/gitcommitvalidator)\n[![last version release date](https://img.shields.io/github/release-date/DWTechs/GitCommitValidator)](https://www.npmjs.com/package/@dwtechs/gitcommitvalidator)\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**[GitCommitValidator](https://github.com/DWTechs/GitCommitValidator)** is an open source git commit message validator library.\n\n## Motivation\n\nThe goal of this library is to provide an easy way to check if the current commit message is valid before pushing it to the remote.\n\nIt's a good way to help developers keep their commit messages 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/conventional-commit/).\n\nYou can also set your own rules using [custom patterns](#patterns).\n\nYou can validate branch names as well with [GitBranchValidator](https://github.com/DWTechs/GitBranchValidator)\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/gitcommitvalidator -g\n```\n\n### Yarn\n\n```bash\n$ yarn add @dwtechs/gitcommitvalidator -g\n```\n\n### Locally\n\nAlternatively, if you are planning to use GitCommitValidator 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/gitcommitvalidator --save-dev\n```\n\n```bash\n$ yarn add @dwtechs/gitcommitvalidator --dev\n```\n\n## Usage\n\n**This library is meant to be used in the Git \"commit-msg\" hook.**\nThus it is not bound to Javascript application only and can be used by any git repository.\n\nOn server side hooks, it can be installed for \"pre-receive\" or \"update\" hook.\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### Command line\n\n```bash\n$ gcvalidator --src \u003ccommit-message-file\u003e\n```\n\nAlternatively if you did not install GitCommitValidator globally you can use npx.\n\n```bash\n$ npx gcvalidator --src \u003ccommit-message-file\u003e\n```\n\n\n### get the commit message\n\nThe commit-msg hook takes one parameter, which is the path to a temporary file that contains the commit message written by the developer.\nTherefore, you need to provide the path of this file:\n\n```bash\n$ gcvalidator --src $1\n```\nWhere $1 should be equal to something like : .git/COMMIT_EDITMSG\n\nLe library will then read the file in order to get the commit message.\n\n### Patterns\n\n#### Default patterns \n\n| name       | Pattern             |\n| :--------- | :------------------ |\n| commit     | **^(build\\|ci\\|doc\\|feat\\|fix\\|perf\\|refactor\\|style\\|test\\|chore\\|revert)\\([a-z0-9]{2,16}\\): \\[[A-Za-z0-9\\\\#-]{2,12}\\] [A-Za-z0-9 !-_]{5,140}$** |\n| merge      | **^Merge branch '([a-zA-Z0-9\\\\#\\-_:\\/\\\\.\\+]{5,65})' of ([a-zA-Z0-9\\\\#\\-_:\\/\\\\.\\+]{10,90})$** |\n\n\nThe commit default pattern follows the principles described [here](https://dwtechs.github.io/efficient-git/conventional-commit/).\nWhich is a simplified version of conventional commits.\n\nThe merge default pattern is the default merge pattern used when Git is merging branches.\n\n#### Custom patterns\n\nYou can use your own custom patterns by adding an optional regexp :\n\n```bash\n$ gcvalidator --src \u003ccommit-message-file\u003e --patterns \"^(feat|fix)\\\\([a-z0-9]{2,16}\\\\): \\\\[[A-Z0-9]{2,25}\\\\] [a-z0-9_\\\\. -]{3,60}$\"\n```\n\nYou can use several patterns if needed : \n\n```bash\n$ cd \u003cgit-project\u003e\n$ gcvalidator --src \u003ccommit-message-file\u003e --patterns \"pattern1\" \"pattern2\" \"pattern3\"\n```\n\nIf one of them is valid, the commit message will be valid.\n\n\n### Message\n\nYou can customize the end of the error message :\n\n```bash\n$ gcvalidator --src \u003ccommit-message-file\u003e --message \"You can learn more about commit message conventions of this project on https://dwtechs.github.io/efficient-git/conventional-commit/\"\n```\n\n### Prompt\n\nIf the commit message 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$ gcvalidator --src \u003ccommit-message-file\u003e --continue\n```\n\nIn this case the user will be prompted about the invalid commit. 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$ gcvalidator --help\n```\n\n### Workflow integration\n\nValidate commit messages on commit-msg hook by adding the following code in the .git/hooks/commit-msg file : \n\n```bash\ngcvalidator -src \"$1\"\n```\n\nYou can use GitBranchValidator as well : \n\n```bash\ngbvalidator \u0026\u0026 gcvalidator -src \"$1\"\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## options\n\n| Option       | Alias |  Type   |                                                                                                             description |\n| :----------  | :---: | :-----: | ----------------------------------------------------------------------------------------------------------------------: |\n| --src        |  -s   | string  |                                  The path of the temporary file containing the commit message (ex: .git/COMMIT_EDITMSG) |\n| --patterns   |  -p   | string  |                                                                      Use custom regexps. 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 commit message is not valid, instead of stopping the process. Does not work if used in Git kooks |\n| --help       |  -h   | boolean |                                                                                               Learn about library usage |\n\n\n## Contributors\n\nGitCommitValidator 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/GitCommitValidator/blob/master/contributor.md)** for detailed installation guide.\n\n## License\n\n**[MIT](https://github.com/DWTechs/GitCommitValidator/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| prompts            | 2.4.2 |","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwtechs%2Fgitcommitvalidator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdwtechs%2Fgitcommitvalidator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwtechs%2Fgitcommitvalidator/lists"}