[maintainer-tools] github-merge-pr: add check for working on clean branch

LEDE Commits lede-commits at lists.infradead.org
Wed Jan 11 07:23:12 PST 2023


ansuel pushed a commit to maintainer-tools.git, branch master:
https://git.openwrt.org/fe709c1d4b5696729d66ea224f0c3494d2a0e98c

commit fe709c1d4b5696729d66ea224f0c3494d2a0e98c
Author: Christian Marangi <ansuelsmth at gmail.com>
AuthorDate: Wed Jan 11 16:21:11 2023 +0100

    github-merge-pr: add check for working on clean branch
    
    With error it may happen to work on a dirty branch and unintended
    changes may be merged on merging a different pull request.
    
    Add a check for it and exit with an error text.
    
    Signed-off-by: Christian Marangi <ansuelsmth at gmail.com>
---
 github-merge-pr.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/github-merge-pr.sh b/github-merge-pr.sh
index f8758d3..f7325db 100755
--- a/github-merge-pr.sh
+++ b/github-merge-pr.sh
@@ -107,6 +107,11 @@ fi
 echo "Returning to $BRANCH"
 $GIT checkout $BRANCH
 
+if [ -n "$($GIT log origin/$BRANCH..HEAD)" ]; then
+	echo "Working on dirty branch for $BRANCH! Please reset $BRANCH to origin/$BRANCH" >&2
+	exit 10
+fi
+
 echo "Actually merging the PR #$PRID from branch $PR_USER/$PR_BRANCH"
 if ! $GIT merge --ff-only $PR_USER/$PR_BRANCH; then
 	echo "Failed to merge $PR_USER/$PR_BRANCH on $BRANCH" >&2




More information about the lede-commits mailing list