Closes #2271: fix hooks for github

This commit is contained in:
sfrevel 2023-05-26 13:36:08 +02:00 committed by Alex
parent 7e0b1067de
commit 983f2ae8af
2 changed files with 7 additions and 7 deletions

View File

@ -16,7 +16,7 @@ Release Notes:
- [ ] After integration of the pull request, I verified our [bluemix test environment](http://taskana.mybluemix.net/taskana) is not broken - [ ] After integration of the pull request, I verified our [bluemix test environment](http://taskana.mybluemix.net/taskana) is not broken
### Verified by the reviewer: ### Verified by the reviewer:
- [ ] Commit message format → TSK-XXX: Your commit message. - [ ] Commit message format → (Closes) #<Issue Number>: Your commit message. i.e. Closes #2271: Your commit message.
- [ ] Submitter's update to [documentation](https://taskana.atlassian.net/wiki/spaces/TAS/overview) is sufficient - [ ] Submitter's update to [documentation](https://taskana.atlassian.net/wiki/spaces/TAS/overview) is sufficient
- [ ] SonarCloud analysis meets our standards - [ ] SonarCloud analysis meets our standards
- [ ] Update of the [current release notes](https://taskana.atlassian.net/wiki/spaces/TAS/pages/1281392672/Current+Release+Notes+Taskana) reflects changes - [ ] Update of the [current release notes](https://taskana.atlassian.net/wiki/spaces/TAS/pages/1281392672/Current+Release+Notes+Taskana) reflects changes

View File

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