[maintainer-tools PATCH 2/4] github-merge-pr: Add option for no remote operations

Hauke Mehrtens hauke at hauke-m.de
Sat Jul 6 09:07:23 PDT 2024


This adds the new option GITHUB_NO_PUSH which will prevent the script
from doing any changes to remote repositories.

Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 github-merge-pr.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/github-merge-pr.sh b/github-merge-pr.sh
index db49c92..76aec20 100755
--- a/github-merge-pr.sh
+++ b/github-merge-pr.sh
@@ -158,6 +158,21 @@ if [ "$(echo "$PR_INFO" | jq -r ".maintainer_can_modify")" == "true" ]; then
 		exit 9
 	fi
 
+	if [ "$GITHUB_NO_PUSH" = "1" ]; then
+		echo "next commands:"
+		if [ "$(echo "$PR_INFO" | jq -r ".maintainer_can_modify")" == "true" ]; then
+			echo "$GIT push $PR_USER HEAD:$PR_BRANCH --force"
+			echo "$GIT checkout $BRANCH"
+			echo "$GIT merge --ff-only $PR_USER/$PR_BRANCH"
+		else
+			echo "$GIT checkout $BRANCH"
+			echo "$GIT merge --ff-only $LOCAL_PR_BRANCH"
+		fi
+		echo "$GIT push"
+		echo "$GIT branch -D $LOCAL_PR_BRANCH"
+		exit 20
+	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
-- 
2.45.2




More information about the openwrt-devel mailing list