Skip to content

Commit 6703885

Browse files
authored
Update the gather PR logic for release.sh (#509)
<!-- Thank you for contributing! Please make sure that your code changes are covered with tests. In case of new features or big changes remember to adjust the documentation. In case of an existing issue, reference it using one of the following: closes: #ISSUE related: #ISSUE How to write a good git commit message: http://chris.beams.io/posts/git-commit/ --> ## What *Describe what the change is solving* ## How *Describe the solution* ## Breaking Changes *Are there any breaking changes in this PR?*
2 parents 1688179 + 0596c82 commit 6703885

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

scripts/release.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ function gather_prs () {
9090
fi
9191

9292
# format: <commit-sha> <commit-msg> ()<pr-number>)
93-
git log --pretty=format:"%h %s" --merges --grep="Merge pull request" $1..$2 \
93+
git log --pretty=format:"%h %s" --merges --grep="#\d+" $1..$2 \
9494
| while read line ; do
95-
commit_sha=$(echo $line | awk '{print $1}') # first field
96-
commit_msg=$(echo $line | awk '{$1=$NF=""; print }' | sed 's/^\ *//') # 2nd through 2nd-to-last fields, trim leading whitespace
97-
pr_number=$(echo $line | awk '{print $NF}' | tr -d '()#') # last field, remove parens and hash
98-
echo "- $commit_msg by @<gh-user> <$(git show -s --format='%an' $commit_sha)> in [#${pr_number}](https://github.com/ngrok/ngrok-operator/pull/${pr_number})"
95+
commit_sha=$(echo "$line" | awk '{print $1}') # first field
96+
commit_msg=$(echo "$line" | awk '{$1=""; if ($NF ~ /[(]#[0-9]+[)]/) {$NF=""} ; print }' | sed 's/^\s*//' | sed 's/\s*$//') # 2nd through 2nd-to-last fields, trim leading and trailing whitespace, remove trailing (#PR) field
97+
pr_number=$(echo "$line" | grep -o -E '(\s|[(])#[0-9]+(\s|[)])' | tr -d ' ()#') # find the PR number, remove parens, spaces, and hash
98+
echo "- $commit_msg by @<gh-user> <$(git show -s --format='%ae' $commit_sha)> in [#${pr_number}](https://github.com/ngrok/ngrok-operator/pull/${pr_number})"
9999
done
100100
}
101101

0 commit comments

Comments
 (0)