Smart commit on Bitbucket for JIRA
Smart Commits allow repository committers to perform actions such as transitioning JIRA Software issues or creating Crucible code reviews by embedding specific commands into their commit messages
The basic command line syntax for a Smart Commit message is:
<ignored text> <ISSUE_KEY> <ignored text> #<COMMAND> <optional COMMAND_ARGUMENTS>
What can be done:
comment on issues
- record time tracking information against issues
- transition issues to any status defined in the JIRA Software project’s workflow.
This post contains information on how to avoid the commit messages formatting mistakes
However we have,
git commit --amend
to change the git commit message later on . It’s useful to maintain a format to avoid later on changes on git commit messages
How to add Git formatter to avoid commit message mistakes?
Git formatter checks for the format of the commit messages and only allows which satisfies the format of smart commits
By this way we can avoid the mistakes which could happen in commit message formats.
To add Git formatter we need to replace a file in the .Git folder of your local git repository.
Open hooks folder in .Git folder on your local repository
Rename the commit-msg.sample file to commit-msg
mv commit-msg.sample commit-msg
Now edit the file
sudo vim commit-msg
Replace it with following content
#!/usr/bin/env bash # set this to your active development branch develop_branch="master" current_branch="$(git rev-parse --abbrev-ref HEAD)" # only check commit messages on main development branch [ "$current_branch" != "$develop_branch" ] && exit 0 # regex to validate in commit msg commit_regex='((YOURBOARD-[0-9s]+)+s+([a-zA-Z]+)?s?((#(in-review|to-do|in-progress|done)s?([a-zA-Z]+)?[s]?)+s?)|merge|rebase)' error_msg="Commit message rejected!. Your commit message is missing either a JIRA Issue ('YOURBOARD-999') with status '#(in-review|to-do|in-progress|done)' or 'merge'" if ! grep -iqE "$commit_regex" "$1"; then echo "$error_msg" >&2 exit 1 fi
write and quit
Now, the formatter is setup
Whenever we try to add a git commit message formatter checks for the format, If that doesn’t satisfy it’ll reject the commit message, So that it’s easy to keep check on the smart commit message format.
Sometimes it is necessary to run a website for internal purpose within organisation or you might be want to share […]
By Murugan D
Principles to adhere to while designing mobile app’s In mobile app development, the UI (user interface) and UX (user experience) […]
By Punith B M