Skip to content

Commit c3bc383

Browse files
Merge pull request #1446 from snyk/fix/issue-tagging-script-regex
Fix issue parsing in issue tagging script
2 parents 7278969 + 9b20cb9 commit c3bc383

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

scripts/issue-tagging.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ if ! $GHCLI_BIN auth status &> /dev/null; then
2828
exit 1
2929
fi
3030

31+
echo "Finding merged pull requests between $BASE_TAG and $LATEST_TAG..."
32+
3133
# Compare $BASE_TAG branch with the latest tag
3234
# Keep IDs of merged pull requests
3335
PRs=$(git log --pretty=oneline "$BASE_TAG"..."$LATEST_TAG" | grep 'Merge pull request #' | grep -oE '#[0-9]+' | sed 's/#//')
@@ -36,7 +38,7 @@ PRs=$(git log --pretty=oneline "$BASE_TAG"..."$LATEST_TAG" | grep 'Merge pull re
3638
EXIT_CODE=0
3739
ISSUES=()
3840
for pr in $PRs; do
39-
id=$($GHCLI_BIN pr view "$pr" --json body | grep -oE 'Related issues | (.*)?[0-9]+(.*)?\|' | sed 's/[^[:digit:]]//g' | sed -z 's/\n//g' || true)
41+
id=$($GHCLI_BIN pr view "$pr" --json body | grep -oE '(Related issues \| )(.*)?[0-9]+(.*|\r|\n)?(\|)' | sed 's/[^[:digit:]]//g' | sed -z 's/\n//g' || true)
4042
if [ -z "$id" ]; then
4143
continue
4244
fi
@@ -48,6 +50,10 @@ for pr in $PRs; do
4850
ISSUES+=("$id")
4951
done
5052

53+
# Remove duplicate IDs
54+
# This can happen when we release using a separate branch (e.g. patch releases)
55+
mapfile -t ISSUES < <(printf "%s\n" "${ISSUES[@]}" | sort -u)
56+
5157
echo "Creating milestone $LATEST_TAG in github.com/$REPO"
5258
curl -X POST \
5359
-H "Accept: application/vnd.github.v3+json" \

0 commit comments

Comments
 (0)