Created
May 23, 2021 11:23
-
-
Save DineshSolanki/165dc22763214bdbd6320ebe6c86fc62 to your computer and use it in GitHub Desktop.
Extract and commit with jira ID in commit message if jira id exist in branch name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -eq 0 ]; then | |
echo "No commit message provided" | |
exit 1 | |
fi | |
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') | |
IFS='/' read -r id bname<<< "$branch" | |
if test -z $bname | |
then | |
IFS='_' read -r id bname<<< "$branch" | |
fi | |
IFS='_' read -r id bname<<< "$bname" | |
commitMessage="${id} : ${1}" | |
printf "This will be commit message - ${commitMessage}\n" | |
read -n 1 -s -r -p "Press any key to continue" | |
git commit -m "$commitMessage" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment