Last active
October 13, 2023 19:20
-
-
Save vladimir-bebeshko/1dcb3a8b33342306c9baba88a9703656 to your computer and use it in GitHub Desktop.
Extract JIRA ticket name from the branch name and prepare commit message
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 | |
JIRA_TAG_PATTERN="mob-[0-9]+" | |
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD 2> /dev/null \ | |
| grep -oiE "$JIRA_TAG_PATTERN" \ | |
| tr '[:lower:]' '[:upper:]') | |
USER_MSG=$(cat $1) | |
MSG=$(echo $USER_MSG | tr '[:upper:]' '[:lower:]') | |
if [[ -n "$BRANCH_NAME" && !($MSG =~ $JIRA_TAG_PATTERN) ]]; then | |
sed -i '' "1s/^/$BRANCH_NAME /g" $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment