mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-07 21:37:02 +09:00
27 lines
No EOL
877 B
Bash
Executable file
27 lines
No EOL
877 B
Bash
Executable file
#!/bin/bash
|
|
# The script below adds the branch name automatically to
|
|
# every one of your commit messages. The regular expression
|
|
# 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]+"
|
|
|
|
# Find current branch name
|
|
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
|
|
COMMIT_MSG_FILE=$1
|
|
COMMIT_TEXT=$(cat "$COMMIT_MSG_FILE")
|
|
|
|
if [[ -z "$BRANCH_NAME" ]]; then
|
|
echo "Commit message validation failed: no branch name!"; exit 1
|
|
fi
|
|
|
|
# Extract issue id from branch name
|
|
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
|
|
fi
|
|
|
|
if [[ "$COMMIT_TEXT" != "DROID-"* ]]; then
|
|
echo "$ISSUE_ID" "$COMMIT_TEXT" > "$COMMIT_MSG_FILE"
|
|
fi |