[openssl-commits] [tools] master update

Richard Levitte levitte at openssl.org
Tue Oct 23 16:17:01 UTC 2018


The branch master has been updated
       via  2d16f8da11fe0bab487d936f13a63ea8fba5204e (commit)
       via  b747cccd90b142bcfa7c264af6c3aba50d233f82 (commit)
      from  16fe6d400dcef56b5ffbe6ddc416cbc77bff7782 (commit)


- Log -----------------------------------------------------------------
commit 2d16f8da11fe0bab487d936f13a63ea8fba5204e
Author: Dr. Matthias St. Pierre <Matthias.St.Pierre at ncp-e.com>
Date:   Sun Oct 14 14:05:09 2018 +0200

    cherry-checker: initial commit
    
    usage: cherry-checker [-h] [-a] [-s] [-r]
    
    Shows the commits in 'master...OpenSSL_1_1_1-stable' which are eligible for
    cherry-picking. A commit is considered cherry-picked, if there is another
    commit on the "other side" which introduces an equivalent patch. For details,
    see the documentation of the '--cherry-mark' option in the git-log(1) manpage.
    
    optional arguments:
      -h, --help    show this help message and exit
      -a, --all     Show all commits, also those which have been cherry-picked.
      -s, --sort    Sort commits w.r.t. pull request number and author date.
      -r, --remote  Compare the remote branches instead of the local ones.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    (Merged from https://github.com/openssl/tools/pull/32)

commit b747cccd90b142bcfa7c264af6c3aba50d233f82
Author: Richard Levitte <levitte at openssl.org>
Date:   Sat Sep 22 23:06:18 2018 +0200

    gitaddrev: do lowercase when checking CLA entries
    
    We know that we lowercase all email addresses in the CLA database, so
    we need to lowercase the identity that we use there, but nowhere else.

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

Summary of changes:
 review-tools/cherry-checker | 152 ++++++++++++++++++++++++++++++++++++++++++++
 review-tools/gitaddrev      |   6 +-
 2 files changed, 155 insertions(+), 3 deletions(-)
 create mode 100755 review-tools/cherry-checker

diff --git a/review-tools/cherry-checker b/review-tools/cherry-checker
new file mode 100755
index 0000000..d65e801
--- /dev/null
+++ b/review-tools/cherry-checker
@@ -0,0 +1,152 @@
+#!/usr/bin/env python3
+
+import argparse
+import subprocess
+import re
+import sys
+
+left  = "master"
+right = "OpenSSL_1_1_1-stable"
+
+
+def parse_arguments():
+    parser = argparse.ArgumentParser(
+        description = """Shows the commits in '{left}...{right}'
+        which are eligible for cherry-picking. A commit is considered
+        cherry-picked, if there is another commit on the "other side"
+        which introduces an equivalent patch.
+        For details, see the documentation of the '--cherry-mark' option
+        in the git-log(1) manpage.
+        """.format(left=left, right=right))
+
+    parser.add_argument(
+        '-a', '--all',
+        action = 'store_true',
+        help = "Show all commits, also those which have been cherry-picked."\
+        )
+
+    parser.add_argument(
+        '-s', '--sort',
+        action = 'store_true',
+        help = "Sort commits w.r.t. pull request number and author date."\
+        )
+
+    parser.add_argument(
+        '-r', '--remote',
+        action = 'store_true',
+        help = "Compare the remote branches instead of the local ones."\
+        )
+
+    args = parser.parse_args()
+
+    return args
+
+
+def check_openssl_git_repo():
+    """Checks whether we're inside a openssl.git downstrem repository"""
+    try:
+        if "/openssl.git" in subprocess.check_output(
+                ["git", "remote", "-v"]
+        ).decode():
+            return True;
+    except:
+        pass
+
+    return False
+
+
+def get_remote():
+    try:
+        return subprocess.check_output(
+            ["git", "config", "branch.master.remote"]
+            ).decode().trim()
+    except:
+        return "origin"
+
+
+def pick_cherries(left, right, all = False):
+    """Lists all commits from the symmetric difference of left and right
+
+    By default, all commits are omitted which have an 'equivalent' commit
+    on the other side, unless 'all' == True.
+    """
+
+    git_command = [
+        "git", "log", "--oneline", "--cherry-mark", "--left-right",
+        left + "..." + right, "--pretty=%at;%m;%h;%s"
+    ]
+
+    regex   = re.compile("|".join([
+        # The standard pull request annotation
+        "\(Merged from https://github.com/openssl/openssl/pull/([0-9]+)\)",
+        # @kroeck's special pull request annotation ;-)
+        "GH: #([0-9]+)"
+    ]))
+
+    for line in subprocess.check_output(git_command).decode().splitlines():
+
+        timestamp, branch, commit, subject = line.split(";")
+
+        if branch == '=' and not all:
+            continue
+
+        # shorten overlong subject lines
+        if len(subject) > 70:
+            subject = subject[:70] + "..."
+
+        # search commit message for pull request number
+        message = subprocess.check_output(
+            ["git", "show", "--no-patch", commit]
+        ).decode()
+
+        match = regex.search(message)
+        if match:
+            if match.group(1):
+                prnum = match.group(1)
+            else:
+                prnum = match.group(2)
+        else:
+            prnum = "????"
+
+        yield prnum, timestamp, branch, commit, subject
+
+
+
+if __name__ == '__main__':
+    args = parse_arguments()
+
+    if not check_openssl_git_repo():
+        print("cherry-checker: Not inside an openssl git repository.", file=sys.stderr)
+        sys.exit(1)
+
+
+    if args.remote:
+        remote = get_remote()
+        left  = remote+"/"+left
+        right = remote+"/"+right
+
+    commits = pick_cherries(left, right, args.all)
+
+    if args.sort:
+        commits = sorted(commits, reverse=True)
+
+    print("""These cherries are hanging on the git-tree:
+
+  <-  {left}
+  ->  {right}
+  ==  both
+
+ prnum | br |   commit   |   subject
+ ----- | -- | ---------- | -------------------------------------------""".format(
+         left = left,
+         right = right))
+
+    branch_marker = { '<': '<-', '>': '->', '=' : '==' }
+
+    try:
+        for prnum, _, branch, commit, subject in commits:
+            print(' #{:>4} | {} | {} | {} '.format(
+                prnum, branch_marker[branch], commit, subject
+            ))
+    except subprocess.CalledProcessError as e:
+        print(e, file=sys.stderr)
diff --git a/review-tools/gitaddrev b/review-tools/gitaddrev
index 18930b4..08cc5d8 100755
--- a/review-tools/gitaddrev
+++ b/review-tools/gitaddrev
@@ -36,7 +36,7 @@ sub try_add_reviewer {
     my $id2 = $id =~ /^\@(.*)$/ ? { github => $1 } : $id;
     my $rev = $query->find_person_tag($id2, 'rev');
     if ($rev) {
-	my $cla = $query->has_cla($rev);
+	my $cla = $query->has_cla(lc $rev);
 	if ($cla) {
 	    unless (grep {$_ eq $rev} @reviewers) {
 		$omccount++ if $query->is_member_of($id2, 'omc');
@@ -50,7 +50,7 @@ sub try_add_reviewer {
     } else {
 	push @unknown_reviewers, $id
 	    unless grep {$_ eq $id} @unknown_reviewers;
-	unless ($id =~ m|^.+\@.*$| && $query->has_cla($id)) {
+	unless ($id =~ m|^.+\@.*$| && $query->has_cla(lc $id)) {
 	    push @nocla_reviewers, $id
 		unless grep {$_ eq $id} @nocla_reviewers;
 	}
@@ -65,7 +65,7 @@ foreach (@ARGV) {
 	    my $email_id = (grep { ref($_) eq "" && $_ =~ m|\@| } @$_)[0];
 	    my $rev = $query->find_person_tag($email_id, 'rev');
 	    my $omc = $query->is_member_of($email_id, 'omc');
-	    next unless $query->has_cla($rev);
+	    next unless $query->has_cla(lc $rev);
 	    next unless $query->is_member_of($email_id, 'commit') || $omc;
 	    my @ids =
 		sort grep { $_ =~ /^[a-z]+$/ || $_ =~ /^\@(?:\w|\w-\w)+$/ }


More information about the openssl-commits mailing list