github-merge-pr: Prevent multiple Link: https://github.com/$REPO/pull/$PRID master
authorChristian Marangi <ansuelsmth@gmail.com>
Sat, 16 Nov 2024 14:00:45 +0000 (15:00 +0100)
committerChristian Marangi <ansuelsmth@gmail.com>
Sat, 16 Nov 2024 14:00:45 +0000 (15:00 +0100)
Link: https://github.com/$REPO/pull/$PRID
included in the commit by removing any already present entry with the
same link.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
github-merge-pr.sh

index 1bd3e2f0b072146f66a42fb7142817edcc9e078d..825ff0baeda84db1a62f7df7ffef22c70fffded0 100755 (executable)
@@ -138,6 +138,14 @@ if [ "$(echo "$PR_INFO" | jq -r ".maintainer_can_modify")" == "true" ] || [ "$IG
                exit 9
        fi
 
                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\"
        # 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\"