Skip to content

Instantly share code, notes, and snippets.

@whalemare
Last active July 15, 2019 09:49
Show Gist options
  • Save whalemare/a838e991b5c5203242cb6c75ec535f73 to your computer and use it in GitHub Desktop.
Save whalemare/a838e991b5c5203242cb6c75ec535f73 to your computer and use it in GitHub Desktop.
Add link to redmine ticket by working branch name
message=$(cat "$1")
currentBranch=$(git rev-parse --abbrev-ref HEAD)
currentBranch=$(echo "$currentBranch" | grep -o '[a-zA-Zа-яА-Я]\+-\d*')
echo "current ticket = $currentBranch"
countTrackerWords=$(echo "$message" | grep -w -c Tracker)
if [ $countTrackerWords == 0 ] && [ ! -z $currentBranch ]
then {
echo ""
echo "Redmine:"
echo "refs $currentBranch"
} >> "$1"
fi
message=$(cat "$1")
currentBranch=$(git rev-parse --abbrev-ref HEAD)
currentBranch=$(echo "$currentBranch" | grep -o '[a-zA-Zа-яА-Я]\+-\d*')
echo "current ticket = $currentBranch"
countTrackerWords=$(echo "$message" | grep -w -c Tracker)
if [ $countTrackerWords == 0 ] && [ ! -z $currentBranch ]
then {
echo ""
echo "Tracker:"
echo "$currentBranch"
} >> "$1"
fi
@whalemare
Copy link
Author

cat commit-msg
echo "CTRL+V text here" > commit-msg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment