0.0.10 • Published 3 months ago

@humankode/git-inject-jira-ticket v0.0.10

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

git-inject-jira-ticket Build status @humankode/git-inject-jira-ticket on npm

A git hook script to automatically inject the Jira ticket in a commit message

For example:

branch:

  • feature-JIRA-1234
  • or feature-JIRA-1234-implement-caching
  • or feature/JIRA-1234-implement-caching
  • or feature/JIRA-1234/implement-caching etc.

commit:

git commit -m "implement caching"

//=> JIRA-1234: implement caching

Usage

Install and configure Husky

.husky/prepare-commit-msg

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --yes @humankode/git-inject-jira-ticket@latest

Zero config by default

Zero configuration by default.

If no configuration specified, it will use JIRA-1234 as the Jira ticket pattern.

Configuration

To override the default configuration, place a file called gitInjectJiraTicket.json in your root directory.

Refer to the Configuration interface for all options.

Example configurations

1. Override the Jira Project Key

gitInjectJiraTicket.json

{
  "jiraIssuePrefix": "FOO"
}

For example

It will expect Jira tickets to be in the format of FOO-1234

Valid branches would be feature-FOO-1234, feature-FOO-1234-some-message, feature/FOO-1234 etc.

2. Override the allowed branch prefixes

The default allowed branchTypes are feature, hotfix, revert, release, build, ci, docs, fix, performance, refactor and test

To override branchTypes:

To only allow feature and hotfix branch types:

gitInjectJiraTicket.json

{
  "branchConfiguration": {
    "branchTypes": [
      "feature",
      "hotfix"
    ]
  }
}

For example:

these branches would be valid:

  • feature-JIRA-1234
  • or hotfix-JIRA-1234-implement-caching
  • or feature/JIRA-1234-implement-caching
  • or hotfix/JIRA-1234/implement-caching etc.

3. Override the Jira Ticket Number's Number of Expected Digits

The default value for jiraTicketLength is 1, which means that the Jira ticket is expected to have 1 or more digits. For example, these would all be valid: JIRA-1, JIRA-12, JIRA-12324 etc.

To change this to only have 4 digits:

gitInjectJiraTicket.json

{
  "jiraTicketLength": "4"
}

Now only 4 digits would be valid, for example: JIRA-1234

4. Capitalize commit messages

The default value for capitalizeMessage is true.

This capitalizes the first letter of the commit message.

For example:

branch: feature-JIRA-1234

git commit -m "some message. with another sentence"

//=> JIRA-1234: Some message. with another sentence

To override capitalizeMessage:

gitInjectJiraTicket.json

{
  "messageConfiguration": {
    "capitalizeMessage": false
  }
}

Maintainers