diff --git a/hooks/prepare-commit-msg b/hooks/prepare-commit-msg deleted file mode 100755 index daf8d0f..0000000 --- a/hooks/prepare-commit-msg +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -# -# Get the story/issue ID from the input branch name -# -get_id_by_branch () { - SPLITTED_BRANCH=($(echo "$1" | tr '-' '\n')) - STORY_ID="${SPLITTED_BRANCH[0]}" - ISSUE_ID="${SPLITTED_BRANCH[1]}" - - # If the branch name start with a number, is a legacy pivotal story - if [[ $STORY_ID =~ $IS_A_NUMBER_REGEX ]] ; then - echo "[#$STORY_ID]"; - # If the branch name start with -, is a Jira issue - elif [[ $ISSUE_ID =~ $IS_A_NUMBER_REGEX ]] ; then - echo "[#$STORY_ID-$ISSUE_ID]"; - else - echo ""; - fi -} - -# -# Automatically adds story/issue id to every commit message. -# -MAX_MSG_LENGHT=72 -IS_A_NUMBER_REGEX='^[0-9]+$' - -BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) -ID=$(get_id_by_branch "$BRANCH_NAME") - -if [[ ! -z "$ID" ]] ; then - COMMIT_MSG_HEADER=$(cat ${1} | head -n 1) - TOTAL_MSG_LENGHT=$((${#COMMIT_MSG_HEADER}+${#ID}+3)) - if (( $TOTAL_MSG_LENGHT < $MAX_MSG_LENGHT)); then - sed -i '.bak' "1s/^/$ID /" $1 - else - echo "Commit message header longer than ${MAX_MSG_LENGHT} characters" - echo "Message: $COMMIT_MSG_HEADER" - exit 1 - fi -fi