The problem: you want JIRA ticket number in commit descriptions and possibly in the PRs. The solution: automate it.
Setup and usage:
- In the repository place the
prepare-commit-message.shfile from this gist at.git/hooks/prepare-commit-message(without.shextension).chmod +xit. - Name branches like
ECA-333/remove-all-shit-and-add-good-code. - Run
git config --global commit.template=~/.gitmessage. Placegitmessagefrom this gist at~/.gitmessage(don't forget the starting dot). - Use
git commitand wait for the editor, don'tgit commit -mor gitx shennanigans to utilize it. - This way
ECA-333will be grabbed out and used: (A) in the commit header and (B) below the commit description, formatted markdown-ready as a link to our JIRA. Example commit message: - Frequently a PR is just one commit. Pay some efforts to prepare a good commit message. Then PR and enjoy title of your commit grabbed as PR title, and body (and a markdown link to JIRA!) grabbed to PR description.
We need to go deeper:
- Now you possibly want to go further and don't manually copy it across the projects. I have a word to you.
- Run
git config --global init.templatedir=~/.git-templates. - Place
prepare-commit-messagefile from this gist at~/.git-templates/hooks/prepare-commit-message(without.shextension).chmod +xit. - All new repos will now have it.
- In an existing repo run
git init. Don't worry, it won't crash anything, just reinitialize the hooks and other things.
