Last active
October 13, 2025 13:30
-
-
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 hidden or 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 | |
| # | |
| # Succeed on all merge and rebase messages, as evidenced by MERGE_MSG and SQUASH_MSG existing | |
| [ -f "$GIT_DIR"/MERGE_MSG ] || [ -f "$GIT_DIR"/SQUASH_MSG ] && exit 0 | |
| JIRA_TAG_PATTERN="mnlth-[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