Skip to content

Commit 05219ec

Browse files
t8mnhorman
authored andcommitted
ghmerge: Add support for merging into security repo
Also use gh command to fetch the PR commits if available. Reviewed-by: Neil Horman <[email protected]> Reviewed-by: Paul Dale <[email protected]> (Merged from #230)
1 parent 424fabe commit 05219ec

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

review-tools/addrev

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ foreach (@ARGV) {
5252
$my_email = $1;
5353
} elsif (/^--nopr$/) {
5454
$haveprnum = 1;
55+
} elsif (/^--security$/) {
56+
$haveprnum = 1;
5557
} elsif (/^--commit=(.+)$/) {
5658
$args .= "--commit=$1 ";
5759
} elsif (/^--release$/) {

review-tools/ghmerge

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Option style arguments:
1313
--web Merge a web PR (rather than openssl PR)
1414
--perftools Merge a perftools PR (rather than openssl PR)
1515
--fuzz-corpora Merge a PR against fuzz-corpora (rather than openssl PR)
16+
--security Merge a PR in the security repo
1617
--remote <remote> Repo to merge with (rather than git.openssl.org), usually 'upstream'
1718
--target <branch> Merge target (rather than current branch), usually 'master'
1819
--ref <branch> A synonym for --target
@@ -86,6 +87,9 @@ while [ $# -ne 0 ]; do
8687
--fuzz-corpora)
8788
WHAT=fuzz-corpora ; BUILD=no ; shift
8889
;;
90+
--security)
91+
WHAT=security ; REMOTESRVR="github.com" ; shift
92+
;;
8993
--cherry-pick)
9094
shift;
9195
PICK=1;
@@ -167,10 +171,18 @@ if [ "$PRNUM" = "" -o "$TEAM" = "" ] ; then
167171
fi
168172

169173
PR_URL_CONTENTS=$(mktemp /tmp/gh.XXXXXX)
170-
PR_URL=https://api.github.com/repos/openssl/$WHAT/pulls/$PRNUM
171-
if ! wget --quiet $PR_URL -O $PR_URL_CONTENTS; then
172-
echo "Error getting $PR_URL"
173-
exit 1
174+
PR_API=repos/openssl/$WHAT/pulls/$PRNUM
175+
PR_URL=https://api.github.com/$PR_API
176+
if which gh >/dev/null 2>&1 ; then
177+
if ! gh api $PR_API >$PR_URL_CONTENTS; then
178+
echo "Error getting $PR_API"
179+
exit 1
180+
fi
181+
else
182+
if ! wget --quiet $PR_URL -O $PR_URL_CONTENTS; then
183+
echo "Error getting $PR_URL"
184+
exit 1
185+
fi
174186
fi
175187

176188
set -- $(jq -r '[.head.user.login, .head.ref, .head.repo.ssh_url] | join(" ")' $PR_URL_CONTENTS)
@@ -269,6 +281,10 @@ echo
269281
echo Diff against $REMOTE/$TARGET:
270282
git diff $REMOTE/$TARGET
271283

284+
if [ "$WHAT" != "security" ] ; then
285+
ADDPR="--prnum=$PRNUM"
286+
fi
287+
272288
if [ "$INTERACTIVE" == "yes" ] ; then
273289
echo
274290
echo -n "Press Enter to interactively rebase $AUTOSQUASH on $REMOTE/$TARGET: "; read foo
@@ -280,8 +296,8 @@ if [ "$INTERACTIVE" == "yes" ] ; then
280296
fi
281297
REBASING=
282298
echo
283-
echo "Calling addrev $ADDREVOPTS --prnum=$PRNUM $TEAM $REMOTE/$TARGET.."
284-
addrev $ADDREVOPTS --prnum=$PRNUM $TEAM $REMOTE/$TARGET..
299+
echo "Calling addrev $ADDREVOPTS $ADDPR $TEAM $REMOTE/$TARGET.."
300+
addrev $ADDREVOPTS $ADDPR $TEAM $REMOTE/$TARGET..
285301
fi
286302

287303
git checkout $TARGET
@@ -292,7 +308,7 @@ if [ "$INTERACTIVE" != "yes" ] ; then
292308
git merge --ff-only --no-commit --squash $WORK
293309
AUTHOR=`git show --no-patch --pretty="format:%an <%ae>" $WORK`
294310
git commit --author="$AUTHOR"
295-
addrev $ADDREVOPTS --prnum=$PRNUM $TEAM $REMOTE/${TARGET}..
311+
addrev $ADDREVOPTS $ADDPR $TEAM $REMOTE/${TARGET}..
296312
else
297313
# echo -n "Press Enter to merge to $TARGET: "; read foo
298314
echo

0 commit comments

Comments
 (0)