DROID-280 App | Tech | Fix git hook - get only task name (#2476)

This commit is contained in:
Mikhail 2022-08-08 11:30:09 +03:00 committed by GitHub
parent 40e2a8a878
commit bc9fd974e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,10 @@
#!/bin/bash
# The script below adds the branch name automatically to
# every one of your commit messages. The regular expression
# below searches for JIRA issue key's. The issue key will
# below searches for linear issue key's. The issue key will
# be extracted out of your branch name
REGEX_ISSUE_ID="[a-zA-Z0-9,\.\_\-]+-[0-9]+"
REGEX_ISSUE_ID="[a-zA-Z0-9]+-[0-9]+"
# Find current branch name
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
@ -16,7 +16,7 @@ if [[ -z "$BRANCH_NAME" ]]; then
fi
# Extract issue id from branch name
ISSUE_ID=$(echo "$BRANCH_NAME" | grep -o -E "$REGEX_ISSUE_ID" | awk '{print toupper($0)}')
ISSUE_ID=$(echo "$BRANCH_NAME" | grep -o -E "$REGEX_ISSUE_ID" | head -1 | awk '{print toupper($0)}')
if [[ "$ISSUE_ID" != "DROID-"* ]]; then
echo "Commit message validation failed: branch name should contain issue name!"; exit 1