16 lines
556 B
Bash
Executable File
16 lines
556 B
Bash
Executable File
#!/bin/bash
|
|
MSG_FILE=$1
|
|
COMMIT_MESSAGE="$(cat $MSG_FILE)"
|
|
REGEX='^(Close|Closes|Closed|Fix|Fixes|Fixed|Resolve|Resolves|Resolved) #([0-9]+)'
|
|
if [[ $COMMIT_MESSAGE =~ $REGEX ]]; then
|
|
TICKET=${BASH_REMATCH[2]}
|
|
RESULT=$(curl -s https://api.github.com/repos/Taskana/taskana/issues/$TICKET)
|
|
if [[ $RESULT =~ "\"message\": \"Not Found\"" ]]; then
|
|
echo -e "\033[0;31mERROR:\033[0m $TICKET is not a valid GitHub issue"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo -e "\033[0;31mERROR:\033[0m Prefix Git commit messages with the GitHub issue, e.g. Closes #2271: xyz..."
|
|
exit 1
|
|
fi
|