These git hooks and scripts provide a more seamless experience linking git branches and commits to certain jira tickets.
This uses the Smart Commits feature https://confluence.atlassian.com/bitbucket/use-smart-commits-298979931.html
-
Enable Smart Commits https://confluence.atlassian.com/fisheye/enabling-smart-commits-960155641.html
-
Add
prepare-commit-msg
to your.git/hooks
directory in your git repo -
Re-initialize your hooks with
git init
-
Append your
~/.bash_profile
file with the content inbash_profile_additions
-
Re-initialize bash:
source ~/.bash_profile
- Copy a link to a jira ticket (https://peartx.atlassian.net/browse/EXAMPLE-2019)
- In your console run one of your bash functions, for example:
createFeatureBranch https://peartx.atlassian.net/browse/EXAMPLE-2019 new-login-screen
Creates a branch named feature/EXAMPLE-2019-new-login-screen
with one empty commit: "[EXAMPLE-2019] starting work"
- All commmits within properly named branches will prepend the jira ticket to the commit subject, for example:
git commit -m "another empty commit" --allow-empty
In feature/EXAMPLE-2019-new-login-screen
becomes commit message "[EXAMPLE-2019] another empty commit"
Adding this githook to existing repos will break your commit commands on branches that do not match the given regex.