From 3fb0902e167f1cb7362fcbc5f27859f6a09e94c2 Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Thu, 10 Mar 2022 00:23:07 +0100 Subject: [PATCH 1/3] tools/changelog-helper: Ignore non-MERGED PRs --- tools/changelog-helper.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/changelog-helper.sh b/tools/changelog-helper.sh index 6ebd091bfe..02289df4ce 100755 --- a/tools/changelog-helper.sh +++ b/tools/changelog-helper.sh @@ -126,9 +126,14 @@ check_or_add_pr() { return fi checked_ids[$id]=1 - local json=$(gh pr view "${id/#/}" --json title,author) + local json=$(gh pr view "${id/#/}" --json title,author,state) + local state=$(jq -r .state <<<"${json}") local title=$(jq -r .title <<<"${json}" | sanitize_title) local author=$(jq -r .author.login <<<"${json}") + if [[ "${state}" != "MERGED" ]]; then + echo "-> Ignoring PR #${id} as state ${state} != MERGED" + return + fi if grep -qF "#$id" <<<"$changelog"; then return fi From d95ee8c7823924973559ac94cb9ab8e5b4ef4dc4 Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Thu, 10 Mar 2022 00:25:46 +0100 Subject: [PATCH 2/3] tools/changelog-helper: Ignore already listed PRs earlier --- tools/changelog-helper.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/changelog-helper.sh b/tools/changelog-helper.sh index 02289df4ce..ebd3296ca6 100755 --- a/tools/changelog-helper.sh +++ b/tools/changelog-helper.sh @@ -126,6 +126,9 @@ check_or_add_pr() { return fi checked_ids[$id]=1 + if grep -qF "#$id" <<<"$changelog"; then + return + fi local json=$(gh pr view "${id/#/}" --json title,author,state) local state=$(jq -r .state <<<"${json}") local title=$(jq -r .title <<<"${json}" | sanitize_title) @@ -134,9 +137,6 @@ check_or_add_pr() { echo "-> Ignoring PR #${id} as state ${state} != MERGED" return fi - if grep -qF "#$id" <<<"$changelog"; then - return - fi local title_suggestion_in_pr=$(gh pr view "$id" --json body,comments,reviews --jq '(.body), (.comments[] .body), (.reviews[] .body)' | grep -oP '\bCHANGELOG:\s*\K([^\\]{5,})' | tail -n1 | sanitize_title) if [[ "${title_suggestion_in_pr}" ]]; then title="${title_suggestion_in_pr}" From e92000a12cfdf2dae9d0eecb46a9fda1b97fb68e Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Thu, 10 Mar 2022 20:41:54 +0100 Subject: [PATCH 3/3] tools/changelog-helper: Make check for existing PRs more robust https://github.com/jamulussoftware/jamulus/pull/2485#discussion_r823418799 Co-authored-by: Peter L Jones --- tools/changelog-helper.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/changelog-helper.sh b/tools/changelog-helper.sh index ebd3296ca6..0bc0b22aac 100755 --- a/tools/changelog-helper.sh +++ b/tools/changelog-helper.sh @@ -126,7 +126,9 @@ check_or_add_pr() { return fi checked_ids[$id]=1 - if grep -qF "#$id" <<<"$changelog"; then + if grep -qE "#$id\>" <<<"$changelog"; then + # Changelog already lists this PR ID -> nothing to do + # (\> ensures that we only match full, standalone IDs) return fi local json=$(gh pr view "${id/#/}" --json title,author,state)