@@ -30,8 +30,20 @@ Examples:
3030 ghmerge --nobuild --target openssl-3.0 --cherry-pick 3 16051 paulidale"
3131 exit 9
3232}
33+
34+ function check_tools {
35+ command -v jq > /dev/null 2>&1
36+ if [ $? -ne 0 ]
37+ then
38+ >&2 echo " You must install the jq utility for ghmerge to work"
39+ exit 1
40+ fi
41+ }
42+
3343set -o errexit
3444
45+ check_tools
46+
3547WHAT=" "
3648PICK=no
3749INTERACTIVE=yes
@@ -160,12 +172,9 @@ if ! wget --quiet $PR_URL -O $PR_URL_CONTENTS; then
160172 echo " Error getting $PR_URL "
161173 exit 1
162174fi
163- set -- ` python3 -c '
164- from __future__ import print_function
165- import json, sys;
166- input = json.load(sys.stdin)
167- print(str(input["head"]["label"]).replace(":", " "),
168- str(input["head"]["repo"]["ssh_url"]))' < $PR_URL_CONTENTS `
175+
176+ set -- $( jq -r ' [.head.user.login, .head.ref, .head.repo.ssh_url] | join(" ")' $PR_URL_CONTENTS )
177+
169178WHO=$1
170179BRANCH=$2
171180REPO=$3
@@ -175,30 +184,20 @@ if [ -z "$WHO" -o -z "$BRANCH" -o -z "$REPO" ]; then
175184 exit 1
176185fi
177186
178- REPO_CHECK=$( python3 -c '
179- from __future__ import print_function
180- import json, sys
181- rtm_set=0
182- urgent_set=0
183- input = json.load(sys.stdin)
184- # Dont do this check if its not for the openssl repo
185- if (input["base"]["repo"]["name"] != "openssl"):
186- sys.exit(0)
187- for l in input["labels"]:
188- if (l["name"] == "approval: ready to merge"):
189- rtm_set=1
190- if (l["name"] == "severity: urgent"):
191- urgent_set=1
192- if (rtm_set == 0 and urgent_set == 0):
193- print("Not ready to merge")
194- ' < $PR_URL_CONTENTS )
195-
196- if [ " $REPO_CHECK " == " Not ready to merge" ]
187+ TARGET_REPO=$( jq -r ' .base.repo.name' $PR_URL_CONTENTS )
188+ RTM_LABEL=$( jq -r ' .labels[] | select(.name == "approval: ready to merge") | .name' $PR_URL_CONTENTS )
189+ URGENT_LABEL=$( jq -r ' .labels[] | select(.name == "severity: urgent") | .name' $PR_URL_CONTENTS )
190+
191+ if [ " $TARGET_REPO " != " openssl" ]
197192then
198- >&2 echo " This pr has neither the urgent or ready to merge flag set, Won't merge"
193+ >&2 echo " Skipping ready to merge check for non-openssl repo"
194+ elif [ -z " $RTM_LABEL " -a -z " $URGENT_LABEL " ]
195+ then
196+ >&2 echo " This PR has neither the ready to merge or urgent label set, can't merge"
199197 exit 1
200198fi
201199
200+
202201ORIG_REF=` git rev-parse --abbrev-ref HEAD` # usually this will be 'master'
203202STASH_OUT=` git stash`
204203WORK=" copy-of-${WHO} -${BRANCH} "
0 commit comments