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:
parent
b52d97475a
commit
a420b46913
2 changed files with 40 additions and 15 deletions
24
.github/scripts/pr-find-issues-test.sh
vendored
Executable file
24
.github/scripts/pr-find-issues-test.sh
vendored
Executable 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"
|
31
.github/scripts/pr-find-issues.sh
vendored
31
.github/scripts/pr-find-issues.sh
vendored
|
@ -4,26 +4,27 @@ PR="$1"
|
||||||
REPO="$2"
|
REPO="$2"
|
||||||
|
|
||||||
if [ "$REPO" == "" ]; then
|
if [ "$REPO" == "" ]; then
|
||||||
REPO="keycloak/keycloak"
|
REPO="keycloak/keycloak"
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
PR_JSON=$(gh api "/repos/$REPO/pulls/$PR")
|
if [ "$PR" != "" ]; then
|
||||||
PR_BODY=$(echo "$PR_JSON" | jq -r .body)
|
PR_JSON=$(gh api "/repos/$REPO/pulls/$PR")
|
||||||
PR_MERGE_COMMIT_SHA=$(echo "$PR_JSON" | jq -r .merge_commit_sha)
|
PR_BODY=$(echo "$PR_JSON" | jq -r .body)
|
||||||
|
PR_MERGE_COMMIT_SHA=$(echo "$PR_JSON" | jq -r .merge_commit_sha)
|
||||||
|
|
||||||
ISSUES=$(parse_issues "$PR_BODY")
|
ISSUES=$(parse_issues "$PR_BODY")
|
||||||
if [ "$ISSUES" == "" ]; then
|
if [ "$ISSUES" == "" ]; then
|
||||||
COMMIT_JSON=$(gh api "/repos/$REPO/commits/$PR_MERGE_COMMIT_SHA")
|
COMMIT_JSON=$(gh api "/repos/$REPO/commits/$PR_MERGE_COMMIT_SHA")
|
||||||
COMMIT_MESSAGE=$(echo "$COMMIT_JSON" | jq -r .commit.message)
|
COMMIT_MESSAGE=$(echo "$COMMIT_JSON" | jq -r .commit.message)
|
||||||
|
|
||||||
ISSUES=$(parse_issues "$COMMIT_MESSAGE")
|
ISSUES=$(parse_issues "$COMMIT_MESSAGE")
|
||||||
|
fi
|
||||||
|
|
||||||
|
for i in $ISSUES; do
|
||||||
|
echo "$i"
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for i in $ISSUES; do
|
|
||||||
echo "$i"
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue