Adding parsing of "fixes"/"fixed" Keyword and the colon (#25634)

Closes #25633

Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
This commit is contained in:
Alexander Schwartz 2023-12-21 13:49:07 +01:00 committed by GitHub
parent b52d97475a
commit a420b46913
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 15 deletions

24
.github/scripts/pr-find-issues-test.sh vendored Executable file
View file

@ -0,0 +1,24 @@
#!/bin/bash -e
# Use this script to test different variants of a PR body.
source ./pr-find-issues.sh
function testParsing() {
echo -n "$1 -> $2 "
if [ $(parse_issues "$1") != "$2" ]; then
echo "(failure)"
return 1
fi
echo "(success)"
return 0
}
function testFailed() {
echo "Test Failed!"
}
trap 'testFailed' ERR
testParsing "Closes #123" "123"
testParsing "Fixes #123" "123"
testParsing "Fixes: #123" "123"

View file

@ -8,9 +8,10 @@ if [ "$REPO" == "" ]; then
fi fi
function parse_issues() { function parse_issues() {
echo "$1" | grep -i -P -o "(close|closes|closed|resolve|resolves|resolved) #[[:digit:]]*" | cut -d '#' -f 2 | sort -n echo "$1" | grep -i -P -o "(close|closes|closed|resolve|resolves|resolved|fixes|fixed):? #[[:digit:]]*" | cut -d '#' -f 2 | sort -n
} }
if [ "$PR" != "" ]; then
PR_JSON=$(gh api "/repos/$REPO/pulls/$PR") PR_JSON=$(gh api "/repos/$REPO/pulls/$PR")
PR_BODY=$(echo "$PR_JSON" | jq -r .body) PR_BODY=$(echo "$PR_JSON" | jq -r .body)
PR_MERGE_COMMIT_SHA=$(echo "$PR_JSON" | jq -r .merge_commit_sha) PR_MERGE_COMMIT_SHA=$(echo "$PR_JSON" | jq -r .merge_commit_sha)
@ -26,4 +27,4 @@ fi
for i in $ISSUES; do for i in $ISSUES; do
echo "$i" echo "$i"
done done
fi