my $refuse = 0;
my $prnum = 0;
my $verbose = 0;
+my $WHAT = 'openssl';
my $query = OpenSSL::Query->new();
my $skip_reviewer;
my $omccount = 0;
sub try_add_reviewer {
- my $id = shift;
+ my $id = lc(shift);
my $rc = undef;
- my $rev = $query->find_person_tag($id, 'rev');
+ my $id2 = $id =~ /^\@(.*)$/ ? { github => $1 } : $id;
+ my $rev = $query->find_person_tag($id2, 'rev');
if ($rev) {
my $cla = $query->has_cla($rev);
if ($cla) {
unless (grep {$_ eq $rev} @reviewers) {
- $omccount++ if $query->is_member_of($id, 'omc');
+ $omccount++ if $query->is_member_of($id2, 'omc');
push @reviewers, $rev;
}
$rc = $rev;
} else {
push @unknown_reviewers, $id
unless grep {$_ eq $id} @unknown_reviewers;
- unless ($query->has_cla($id)) {
+ unless ($id =~ m|^.+\@.*$| && $query->has_cla($id)) {
push @nocla_reviewers, $id
unless grep {$_ eq $id} @nocla_reviewers;
}
return $rc;
}
-my @commit_message = map { (my $x = $_) =~ s|\R$||; $x } <STDIN>;
-my $trivial = !! grep(/^CLA:\s*Trivial\s*$/i, @commit_message);
-
foreach (@ARGV) {
if (/^--list$/) {
my %list = ();
my $rev = $query->find_person_tag($email_id, 'rev');
my $omc = $query->is_member_of($email_id, 'omc');
next unless $query->has_cla($rev);
- my @ids = sort grep { $_ =~ m|^[a-z][-a-z]*$| } map {
- if (ref($_) eq "HASH") {
- values %$_;
- } else {
- $_;
- }
- } @$_;
+ next unless $query->is_member_of($email_id, 'commit') || $omc;
+ my @ids =
+ sort grep { $_ =~ /^[a-z]+$/ || $_ =~ /^\@(?:\w|\w-\w)+$/ }
+ map {
+ if (ref($_) eq "HASH") {
+ my %h = %$_;
+ map { $_ eq "github" ? '@'.$h{$_} : $h{$_} } keys %h;
+ } else {
+ $_;
+ }
+ } @$_;
foreach (@ids) {
$list{$_} = { tag => $rev, omc => $omc };
}
try_add_reviewer($1);
} elsif (/^--verbose$/) {
$verbose = 1;
+ } elsif (/^--web$/) {
+ $WHAT = 'web';
+ } elsif (/--tools$/) {
+ $WHAT = 'tools'
}
}
+my @commit_message = map { (my $x = $_) =~ s|\R$||; $x } <STDIN>;
+my $trivial = !! grep(/^CLA:\s*Trivial\s*$/i, @commit_message);
+
# If the author is a registered committer, that identity passes as a reviewer
# too. There is a twist, though... see next comment
if (my $rev = try_add_reviewer($ENV{GIT_AUTHOR_EMAIL})) {
# In case the author is unknown to our databases or is lacking a CLA,
# we need to be extra careful to check if this is supposed to be a
# trivial commit.
- my $author = $ENV{GIT_AUTHOR_EMAIL};
+ my $author = lc($ENV{GIT_AUTHOR_EMAIL});
# Note: it really should be enough to check if $author is unknown, since
# the databases are supposed to be consistent with each other. However,
foreach (@commit_message) {
# Start each line with assuming it's not a reviewed-by line
$last_is_rev = 0;
- if (/^\(Merged from https:\/\/github\.com\/openssl\/openssl\/pull\//
- || /^Reviewed-by:\s*(\S.*\S)\s*$/) {
+ if (/^\(Merged from https:\/\/github\.com\/openssl\/$WHAT\/pull\//) {
+ next if $rmrev == 1;
+ $last_is_rev = 1;
+ next; # Because we're rewriting it below
+ # (unless --nopr was given in addrev)
+ } elsif (/^Reviewed-by:\s*(\S.*\S)\s*$/) {
my $id = $1;
next if $rmrev == 1;
$last_is_rev = 1;
# Remove reviewers that are already in the message from our reviewer list
- @reviewers = grep { $_ ne $id } @reviewers if $id;
+ @reviewers = grep { $_ ne $id } @reviewers;
}
print $_,"\n";
}
}
}
-print "(Merged from https://github.com/openssl/openssl/pull/$prnum)\n"
+print "(Merged from https://github.com/openssl/$WHAT/pull/$prnum)\n"
if $prnum;