Skip to content

Instantly share code, notes, and snippets.

@DineshSolanki
Created May 23, 2021 11:23
Show Gist options
  • Save DineshSolanki/165dc22763214bdbd6320ebe6c86fc62 to your computer and use it in GitHub Desktop.
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
#!/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