Skip to content

Commit

Permalink
Quote bash variables (thanks @vzsigmond)
Browse files Browse the repository at this point in the history
  • Loading branch information
bserem committed Oct 1, 2024
1 parent 7453ee0 commit 0f3336d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/git-hooks/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ if git rev-parse -q --verify MERGE_HEAD >/dev/null 2>&1; then
fi

# Check if the commit message starts with the desired pattern
if [[ $commit_message =~ $COMMIT_PATTERN ]]; then
if [[ "$commit_message" =~ "$COMMIT_PATTERN" ]]; then
exit 0
fi

# Get the current branch name
branch_name=$(git rev-parse --abbrev-ref HEAD)

# Try to extract the pattern from the branch name
if [[ $branch_name =~ $BRANCH_PATTERN ]]; then
if [[ "$branch_name" =~ "$BRANCH_PATTERN" ]]; then
ticket_id="${BASH_REMATCH[1]}"
# Prepend the ticket ID to the commit message
echo "$ticket_id: $commit_message" > "$1"
Expand Down

0 comments on commit 0f3336d

Please sign in to comment.