https://github.com/jessedobbelaere/jira-smart-commit
A Node.js githook script that transforms commits into smart commits, prefixed with the JIRA issue tag.
https://github.com/jessedobbelaere/jira-smart-commit
githook husky jira nodejs
Last synced: 11 months ago
JSON representation
A Node.js githook script that transforms commits into smart commits, prefixed with the JIRA issue tag.
- Host: GitHub
- URL: https://github.com/jessedobbelaere/jira-smart-commit
- Owner: jessedobbelaere
- Created: 2017-09-07T00:45:21.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-04-19T03:08:52.000Z (about 3 years ago)
- Last Synced: 2024-11-09T01:09:45.125Z (over 1 year ago)
- Topics: githook, husky, jira, nodejs
- Language: JavaScript
- Size: 113 KB
- Stars: 13
- Watchers: 2
- Forks: 8
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# JIRA Smart Commit

[](https://github.com/jessedobbelaere/jira-smart-commit/releases/latest)
[](https://dependabot.com)
[](http://opensource.org/licenses/MIT)
[](https://www.npmjs.com/package/jira-smart-commit)
[](http://makeapullrequest.com)
A Node.js git hook script to prefix commits automatically with the JIRA ticket, based on a branch name.
## Usage
### Installation
1. Install [Husky](https://www.npmjs.com/package/husky) in your project to configure Git hooks easily.
```bash
npm install --save-dev husky
npx husky init
```
2. Install this package in your project:
```bash
npm install --save-dev jira-smart-commit
```
3. Configure scripts in `package.json`. The script expects his first argument to be the JIRA tag of the project.
```bash
# .husky/commit-msg
npx jira-smart-commit YOUR_JIRA_ISSUE_KEY
```
Alternatively: use a regex to detect the Jira `ISSUE_KEY` in your branch.
- `TAG_MATCHER` - regular expression
- `TAG_MATCH_INDEX` - match index
Example: if your branch names looke like `feature/JRA-1234/some-description` template
```bash
# .husky/commit-msg
TAG_MATCHER=\"^[^/]+/(JRA-[0-9]+)\" TAG_MATCH_INDEX=1 npx jira-smart-commit
```
4. Commit with git like usual. If the branch was prefixed with a JIRA tag, your commit message will get a Jira prefix added with
the same tag.
```
Branch: JRA-411-husky-git-hooks
Commit message: "Add git hooks to project" → "JRA-411 Add git hooks to project"
```