[tools] master update

Dr. Paul Dale pauli at openssl.org
Fri Feb 28 03:03:44 UTC 2020


The branch master has been updated
       via  ed754fa33f1d80887e953a9cd849752d41775401 (commit)
      from  dddec86b763599974ef6f07036b51ee5b3946067 (commit)


- Log -----------------------------------------------------------------
commit ed754fa33f1d80887e953a9cd849752d41775401
Author: Dr. David von Oheimb <David.von.Oheimb at siemens.com>
Date:   Fri Feb 28 13:02:20 2020 +1000

    make addrev exit with 1 in case of failure
    
    improve hint on using --prnum=... in review-tools/addrev
    
    Various tweaks to make ghmerge more usable
    
    - make gcc (rather than clang-3.6) the default for rebuilding
    - take the (SSH version of the) repo URL from the database
    - add 'git pull' to get the latest state of the master
    - add '-i --autosquash' to 'git rebase' and move it before addrev
    - make '--nomerge' (which means interactive rebase) the default
    - show the log of the commits be pushed (after addrev is called)
    - print some more (and slightly improved) info what is going on
    - tweak the safety questions being asked
    
    extend and update documentation of addrev etc. in review-tools/README
    
    add info on HTTPS transfer done by (git)addrev and ghmerge
    also on use of 'https_proxy' and 'no_proxy' env variables
    
    * extend general description
    * make clear that ghmerge calls addrev
    * add description of the ghmerge options
    
    Reviewed-by: Tomas Mraz <tmraz at fedoraproject.org>
    Reviewed-by: Paul Dale <paul.dale at oracle.com>
    (Merged from https://github.com/openssl/openssl/pull/59)

-----------------------------------------------------------------------

Summary of changes:
 review-tools/README         | 66 ++++++++++++++++++++++++++++---------
 review-tools/addrev         | 12 ++++---
 review-tools/ghmerge        | 80 ++++++++++++++++++++++++++++++++-------------
 review-tools/pick-to-branch |  4 +--
 4 files changed, 118 insertions(+), 44 deletions(-)

diff --git a/review-tools/README b/review-tools/README
index 83f7802..3e38c8a 100644
--- a/review-tools/README
+++ b/review-tools/README
@@ -11,7 +11,10 @@ the QueryApp libraries as well.
 Environment
 ===========
 
-Some of the scripts use the information REST API on https://api.openssl.org.
+Some of the scripts use the information REST API on https://api.openssl.org
+while ghmerge also uses https://api.github.com.
+The environment variables 'https_proxy' and 'no_proxy' can be used.
+
 If you have direct access to the databases and want to use that instead, set
 the environment variable OMC to the directory where they are located.
 
@@ -38,12 +41,16 @@ IDs prefixed with a @, or known email addresses if given with --reviewer.
 
 Run 'addrev --list' to ge a list of known reviewer names.
 
+The tool accesses databases on api.openssl.org.
+The environment variables 'https_proxy' and 'no_proxy' can be used.
+The transfer may take many seconds, in particular with the '--list' option.
+
 Examples:
 
-    addrev steve
-    addrev -2 steve
-    addrev -2 steve @richsalz
-    addrev -2 --reviewer=steve --reviewer=rsalz at openssl.org
+    addrev --prnum=1234 steve
+    addrev 1234 -2 steve
+    addrev 1234 -2 steve @richsalz
+    addrev 1234 -2 --reviewer=steve --reviewer=rsalz at openssl.org
 
 gitlabutil
 ----------
@@ -101,16 +108,45 @@ Checkout branch for query 145:
 ghmerge
 -------
 
-ghmerge merges (reviewed and approved!) GitHub pull requests
-
-It works on the current branch, which should be master or one of the stable
-releases.
-
-Usage:
-        ghmerge ### reviewer...
-
-The ### is the GitHub MR number.  The rest of the args are the names of
-the reviewers (passed to addrev; see above).
+ghmerge calls addrev and pushes (reviewed and approved!) GitHub pull requests.
+It includes several safety precautions and questions such as showing the diff,
+showing the resulting commit messages, and (by default) rebuilding everything.
+
+It works on the current branch, which should be 'master' or one of the stable
+releases. The default remote is the first one matching 'git.openssl.org.*(push)'.
+So typically before calling 'ghmerge' one would have done the following:
+
+	git remote -v
+origin	openssl-git at git.openssl.org:openssl.git (fetch)
+origin	openssl-git at git.openssl.org:openssl.git (push)
+	git fetch origin
+	git checkout master
+
+The tool accesses external databases on api.openssl.org and api.github.com.
+The environment variables 'https_proxy' and 'no_proxy' can be used.
+
+Example usage patterns:
+        ghmerge <prnum> <reviewers>...
+        ghmerge --tools --squash <prnum> <reviewer>...
+
+The default commit post-processing operaton is 'git rebase -i --autosquash'.
+
+Available options are:
+
+--noautosquash  Use default interactive post-processing but without '--autosquash'.
+--squash        Use non-interactive post-processing 'git merge --ff-only --squash'.
+--nobuild       Do not use 'opensslbuild'.
+                Else it is invoked with $CC defaulting to "ccache gcc".
+--remote        Select the git remote of the branch to pull from and push to.
+                Default is the first remote matching 'git.openssl.org.*(push)'.
+--tools         Select the 'tools' repository rather than 'openssl'.
+                This implies '--nobuild'.
+--web           Select the 'web' repository rather than 'openssl'.
+                This implies '--nobuild'.
+--trivial       Pass '--trivial' to the invocation of 'addrev'.
+
+The <prnum> is the GitHub PR number.  The rest of the args are the names
+of the reviewers. All this info will be passed to addrev; see above.
 
 
 pick-to-branch
diff --git a/review-tools/addrev b/review-tools/addrev
index 5cadfdb..24032e7 100755
--- a/review-tools/addrev
+++ b/review-tools/addrev
@@ -34,8 +34,8 @@ foreach (@ARGV) {
         $my_email = $1;
     } elsif (/^--nopr$/) {
 	$haveprnum = 1;
-    } elsif (/^--prnum=(.+)$/) {
-        $args .= "--prnum=$1 ";
+    } elsif (/^(--prnum=)?(\d+)$/) {
+        $args .= "--prnum=$2 ";
 	$haveprnum = 1;
     } elsif (/^--commit=(.+)$/) {
         $args .= "--commit=$1 ";
@@ -61,7 +61,7 @@ if ($help) {
     exit(0);
 }
 
-die "Need either --prnum or --nopr flag" unless $haveprnum;
+die "Need either [--prnum=]NNN or --nopr flag" unless $haveprnum;
 
 if ($useself) {
     if (!defined $my_email) {
@@ -71,7 +71,9 @@ if ($useself) {
     $args .= "--myemail=$my_email ";
 }
 
-system("git filter-branch -f --tag-name-filter cat --msg-filter \"gitaddrev $args\" $filterargs");
+my $err = "/tmp/addrev$$";
+system("git filter-branch -f --tag-name-filter cat --msg-filter \"gitaddrev $args\" $filterargs || (echo addrev failed; exit 1)");
+die if $?;
 
 sub usage {
     print STDERR <<"EOF";
@@ -90,7 +92,7 @@ option style arguments:
 --myemail=<email>	Set email address.  Defaults to the result from
 			git configuration setting user.email.
 --nopr			Do not requre a PR number.
---prnum=NNN             Add a reference to GitHub pull request NNN
+[--prnum=]NNN           Add a reference to GitHub pull request NNN
 -<n>			Change the last <n> commits.  Defaults to 1.
 
 non-option style arguments can be:
diff --git a/review-tools/ghmerge b/review-tools/ghmerge
index 1fb70c8..d2da9e6 100755
--- a/review-tools/ghmerge
+++ b/review-tools/ghmerge
@@ -5,7 +5,10 @@ set -o errexit
 WHAT=openssl
 BUILD=yes
 TRIVIAL=""
-MERGE="yes"
+INTERACTIVE=yes
+AUTOSQUASH="--autosquash"
+[ -z ${CC+x} ] && CC="ccache gcc" # the default otherwise is "ccache clang-3.6"
+REMOTE=`git remote -v | awk '/git.openssl.org.*(push)/{ print $1; }' | head -n 1`
 
 if [ ! -d .git ] ; then
     echo Not at top-level
@@ -16,23 +19,30 @@ fi
 while true ; do
     case "$1" in
     --tools)
-        WHAT=tools ; MERGE=yes ; BUILD=no ; shift
+        WHAT=tools ; BUILD=no ; shift
         ;;
     --web)
-        WHAT=web ; MERGE=yes ; BUILD=no ; shift
+        WHAT=web ; BUILD=no ; shift
         ;;
     --trivial)
         TRIVIAL="--trivial" ; shift
         ;;
-    --merge | --squash)
-        MERGE=yes ; shift
+    --noautosquash)
+        AUTOSQUASH="" ; shift
         ;;
-    --nomerge | --nosquash)
-        MERGE=no ; shift
+    --squash)
+        INTERACTIVE=no ; shift
         ;;
     --nobuild)
         BUILD=no ; shift
         ;;
+    --remote)
+        if [ $# -lt 2 ] ; then
+            echo "Missing argument of '$1'"
+            exit 1
+        fi
+        shift; REMOTE=$1; shift
+        ;;
     --)
         shift
         break
@@ -54,14 +64,21 @@ fi
 PRNUM=$1 ; shift
 TEAM=$*
 
-curl -s https://api.github.com/repos/openssl/$WHAT/pulls/$PRNUM >/tmp/gh$$
+PR_URL=https://api.github.com/repos/openssl/$WHAT/pulls/$PRNUM
+if ! wget --quiet $PR_URL -O /tmp/gh$$; then
+    echo "Error getting $PR_URL"
+    exit 1
+fi
 set -- `python -c '
 from __future__ import print_function
 import json, sys;
-print(str(json.load(sys.stdin)["head"]["label"]).replace(":", " "))' </tmp/gh$$`
-rm /tmp/gh$$
+input = json.load(sys.stdin)
+print(str(input["head"]["label"]).replace(":", " "),
+      str(input["head"]["repo"]["ssh_url"]))'        </tmp/gh$$`
 WHO=$1
 BRANCH=$2
+REPO=$3
+rm /tmp/gh$$
 
 if [ -z "$WHO" -o -z "$BRANCH" ]; then
     echo "Don't know from which branch to fetch"
@@ -72,40 +89,59 @@ REL=`git rev-parse --abbrev-ref HEAD`
 WORK="${WHO}-${BRANCH}"
 PREV=
 
-git checkout -b $WORK $REL
+echo -n "Press Enter to pull the latest $REL from $REMOTE: "; read foo
+git pull $REMOTE $REL
 
 function cleanup {
     if [ "$WORK" != "$REL" ]; then
         git checkout -q $REL
         git branch -D $WORK
+        git reset --hard $REMOTE/$REL
     fi
 }
 trap 'cleanup' EXIT
 
-git pull --rebase https://github.com/$WHO/$WHAT.git $BRANCH
-git rebase $REL
+git checkout -b $WORK $REL
+
+# append new commits from $REPO/$BRANCH
+git pull --rebase $REPO $BRANCH
+echo rebasing on $REL
+git rebase $REL || (git rebase --abort; exit 1)
 
 echo Diff against $REL
 git diff $REL
 
-echo -n Press return to merge to $REL: ; read foo
-addrev $TRIVIAL --prnum=$PRNUM $TEAM ${REL}..
+if [ "$INTERACTIVE" == "yes" ] ; then
+    # echo -n "Press Enter to interactively rebase $AUTOSQUASH on $REL: "; read foo
+    git rebase -i $AUTOSQUASH $REL || (git rebase --abort; exit 1)
+    addrev $TRIVIAL --prnum=$PRNUM $TEAM ${REL}..
+fi
+
+echo Log since $REL
+git log $REL..
+
 git checkout $REL
-if [ "$MERGE" == "yes" ] ; then
-    git merge --no-commit --squash $WORK
+if [ "$INTERACTIVE" != "yes" ] ; then
+    echo -n "Press Enter to non-interactively merge --squash to $REL: "; read foo
+    git merge --ff-only --no-commit --squash $WORK
     AUTHOR=`git show --no-patch --pretty="format:%an <%ae>" $WORK`
     git commit --author="$AUTHOR"
+    addrev $TRIVIAL --prnum=$PRNUM $TEAM $REMOTE/${REL}..
 else
-    git rebase $WORK
+    # echo -n "Press Enter to merge to $REL: "; read foo
+    git merge --ff-only $WORK
 fi
 
+echo New log since $REMOTE/$REL
+git log $REMOTE/$REL..
+
 if [ "$BUILD" == "yes" ] ; then
-    echo Rebuilding
-    ( opensslbuild 2>&1 ) | tail -3
+    echo Rebuilding...
+    ( CC="$CC" opensslbuild 2>&1 ) | tail -3
 fi
 
 while true ; do
-    echo -n "Enter YES to push or NO to abort: "
+    echo -n "Enter 'yes' to push to $REMOTE/$REL or 'no' to abort: "
     read x
     x="`echo $x | tr A-Z a-z`"
     if [ "$x" = "y" -o "$x" = "yes" -o "$x" = "n" -o "$x" = "no" ] ; then
@@ -114,5 +150,5 @@ while true ; do
 done
 
 if [ "$x" = "y" -o "$x" = "yes" ] ; then
-    git push origin $REL
+    git push -v $REMOTE $REL
 fi
diff --git a/review-tools/pick-to-branch b/review-tools/pick-to-branch
index 1c385e5..a5dd427 100755
--- a/review-tools/pick-to-branch
+++ b/review-tools/pick-to-branch
@@ -43,7 +43,7 @@ echo "Are these correct?"
 
 while true
 do
-    echo -n "Enter YES to continue or NO to abort: "
+    echo -n "Enter 'yes' to continue or 'no' to abort: "
     read x
     x="`echo $x | tr A-Z a-z`"
     if [ "$x" = "y" -o "$x" = "yes" -o "$x" = "n" -o "$x" = "no" ]
@@ -63,7 +63,7 @@ git cherry-pick -e -x $id
 
 while true
 do
-    echo -n "Enter YES to push or NO to abort: "
+    echo -n "Enter 'yes' to push or 'no' to abort: "
     read x
     x="`echo $x | tr A-Z a-z`"
     if [ "$x" = "y" -o "$x" = "yes" -o "$x" = "n" -o "$x" = "no" ]


More information about the openssl-commits mailing list