diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-02-13 19:24:39 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-02-22 21:31:23 +0000 |
commit | ae6a386fbf52867577d0bf54705fbcecf3197280 (patch) | |
tree | 96cf077899807e95e97bde41447e59b860adc3a8 /git-hooks/gerrit-bot | |
parent | 829e4c9ed995ff1b04b6b9142342be1f93cecec7 (diff) |
move assignment of Sanity-Review JSON field to sanitize-commit
the worker knows gerrit's JSON format and the meaning of the field's
values anyway, so putting the field name there as well actually improves
locality.
Change-Id: If1ee5a5e54bb041244dcc986b6236de504522c2f
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'git-hooks/gerrit-bot')
-rwxr-xr-x | git-hooks/gerrit-bot | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/git-hooks/gerrit-bot b/git-hooks/gerrit-bot index 0c10130..05c444f 100755 --- a/git-hooks/gerrit-bot +++ b/git-hooks/gerrit-bot @@ -42,7 +42,6 @@ use Gerrit::REST; # The worker is run in a local bare clone of the inspected repository. # The magic string @SHA@ is replaced by the commit to be checked. # It is expected to dump a Gerrit ReviewInput JSON entity to stdout. -# It is supposed to return a score (offset by +10). # excluded (optional) # Space-separated list of exclusions of the form <project> or # <project>:<branch>. @@ -143,14 +142,14 @@ sub process_commit($$$$$) $processed{$ref} = 1; my $orig_project = $project; $project =~ s,/$,,; # XXX Workaround QTQAINFRA-381 - my ($score, $verdict) = (undef, {}); + my $verdict = {}; my $message = ""; my $iswip = 0; my @invite; if (defined($EXCLUDED_PROJECTS{$project}) || defined($EXCLUDED_PROJECTS{$project.":".$branch})) { $verbose and print "===== ".strftime("%c", localtime(time()))." ===== excluding commit ".$ref." in ".$project."\n"; - $score = 1; $message = "(skipped)"; + $$verdict{labels}{'Sanity-Review'} = 1; } else { $verbose and print "===== ".strftime("%c", localtime(time()))." ===== processing commit ".$ref." in ".$project."\n"; my $GIT_DIR = $GIT_BASEDIR."/".$project.".git"; @@ -226,9 +225,7 @@ sub process_commit($$$$$) } close VERDICT; die "Worker for commit ".$ref." in ".$project." crashed with signal ".$?.".\n" if ($? & 127); - $score = $? >> 8; - die "Worker returned invalid score ".$score." for commit ".$ref." in ".$project.".\n" if ($score > 20); - $score -= 10; + die "Worker returned non-zero exit code for commit ".$ref." in ".$project.".\n" if ($?); if (length($output) > 50000) { $message = "**** Worker produced an unreasonable amount of output. You should ask the bot maintainers for advice."; push @invite, @MAINTAINERS; @@ -238,7 +235,7 @@ sub process_commit($$$$$) } $verdict = decode_json($output); defined($verdict) or die "cannot decode verdict as JSON\n"; - $$verdict{labels} = { 'Sanity-Review' => $score, 'Code-Review' => ($iswip ? -2 : 0) }; + $$verdict{labels}{'Code-Review'} = ($iswip ? -2 : 0); } } if (@invite) { @@ -260,7 +257,7 @@ sub process_commit($$$$$) print STDERR "Submission of REST verdict for ".$rev." (".$project."/".$ref.") failed: $@\n"; return; } - $verbose and print "Submitted verdict for ".$rev." (".$project."/".$ref."): $score\n"; + $verbose and print "Submitted verdict for ".$rev." (".$project."/".$ref.")\n"; } $| = 1; # make STDOUT autoflush |