This repository houses a local git commit-msg hook that can be configured on developer workstations to ensure a Jira work item number (e.g. PROJECT-123) is included in the first line of the commit message. This ensures server-side Jira and GitHub integration can work seamlessly.
There are multiple different options for you to set this up. Choose one of the below sections.
This option will allow you to specify the hook as a required check for a specific repository. See pre-commit.com for full details and usage of the framework.
-
Install pre-commit if you don't already have it:
pip install pre-commit
-
Add a
.pre-commit-config.yaml
configuration file to the root folder of your repository, with details of this repository:repos: - repo: https://github.com/dalebowie/git_hook_jira_commit_msg.git rev: "1.0" hooks: - id: jira-commit-msg default_install_hook_types: [commit-msg]
-
Run pre-commit for your repository:
pre-commit
Note: step 4 will need to be run any time you do a fresh clone of the repository.
-
Clone this repository to your workstation:
git clone https://github.com/dalebowie/git_hook_jira_commit_msg.git HOOK_DIR="$(pwd)/git_hook_jira_commit_msg/hooks"
-
Set the global hooks path:
git config --global core.hooksPath ${HOOK_DIR}
Note: this procedure needs to be repeated for each clone you perform of a repository. Local git hooks do not get pushed back to origin/upstream.
-
Clone this repository to your workstation:
git clone https://github.com/dalebowie/git_hook_jira_commit_msg.git HOOK_DIR="$(pwd)/git_hook_jira_commit_msg/hooks"
-
Change directories into the root directory of a Git repository that you want to enable the hooks for.
-
Link in the hook files:
git config core.hooksPath ${HOOK_DIR}