From: Christian Marangi Date: Sat, 27 Apr 2024 11:31:33 +0000 (+0200) Subject: github-merge-pr: add Link: tag and Committer SoB X-Git-Url: http://git.openwrt.org/project/luci.git;master?p=maintainer-tools.git;a=commitdiff_plain;h=c1f80d0258a7df9881c064f31d4a6d89ca6706d4 github-merge-pr: add Link: tag and Committer SoB If we can rebase the Pull Request, append the Link: tag and Committer SoB tag to the end of the commit message to better reference the source of the commit and who Approved/Committed. In theory any modification to the commit should always have a SoB hence a committer rebasing the Pull Request should add the SoB tag. Signed-off-by: Christian Marangi --- diff --git a/github-merge-pr.sh b/github-merge-pr.sh index 7f23435..d63b345 100755 --- a/github-merge-pr.sh +++ b/github-merge-pr.sh @@ -120,6 +120,28 @@ if [ "$(echo "$PR_INFO" | jq -r ".maintainer_can_modify")" == "true" ]; then exit 9 fi + # Add to each commit Link: https://github.com/openwrt/openwrt/pull/$PRID + if ! $GIT filter-repo --message-callback " + return message + b\"Link: https://github.com/openwrt/openwrt/pull/$PRID\" + " --refs $BRANCH..$LOCAL_PR_BRANCH; then + echo "Failed to add Link: Pull Request tag" >&2 + exit 9 + fi + + # Remove any previous SoB tag if the Pull Request Author and Committer match + if ! $GIT filter-repo --message-callback " + return message.replace(b\"Signed-off-by: $(git config user.name) <$(git config user.email)>\",b\"\") + " --refs $BRANCH..$LOCAL_PR_BRANCH; then + echo "Failed to remove previous Committer SoB tag" >&2 + exit 9 + fi + + # Add Committer SoB to better reference who merged the thing last + if ! $GIT rebase origin/$BRANCH $LOCAL_PR_BRANCH --exec "git commit -s --amend -C HEAD"; then + echo "Failed to add Committer SoB tag" >&2 + exit 9 + fi + echo "Force pushing $LOCAL_PR_BRANCH to HEAD:$PR_BRANCH for $PR_USER" if ! $GIT push $PR_USER HEAD:$PR_BRANCH --force; then echo "Failed to force push HEAD to $PR_USER" >&2