From deac687606522a8ba4266c294ed6df4cc3288490 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Sat, 16 Nov 2024 15:00:45 +0100 Subject: [PATCH] github-merge-pr: Prevent multiple Link: https://github.com/$REPO/pull/$PRID Prevent multiple Link: https://github.com/$REPO/pull/$PRID from being included in the commit by removing any already present entry with the same link. Signed-off-by: Christian Marangi --- github-merge-pr.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/github-merge-pr.sh b/github-merge-pr.sh index 1bd3e2f..825ff0b 100755 --- a/github-merge-pr.sh +++ b/github-merge-pr.sh @@ -138,6 +138,14 @@ if [ "$(echo "$PR_INFO" | jq -r ".maintainer_can_modify")" == "true" ] || [ "$IG exit 9 fi + # Remove any previous Link: https://github.com/$REPO/pull/$PRID tag + if ! $GIT filter-repo --message-callback " + return message.replace(b\"Link: https://github.com/$REPO/pull/$PRID\n\",b\"\") + " --refs $BRANCH..$LOCAL_PR_BRANCH --force; then + echo "Failed to remove previous Link: https://github.com/$REPO/pull/$PRID tag" >&2 + exit 9 + fi + # Add to each commit Link: https://github.com/$REPO/pull/$PRID if ! $GIT filter-repo --message-callback " return message + b\"Link: https://github.com/$REPO/pull/$PRID\" -- 2.30.2