summaryrefslogtreecommitdiff
path: root/git-hooks/gerrit-bot
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2015-02-12 16:47:32 +0100
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2015-02-13 13:59:19 +0000
commitcbddd3a5a6c9022b456c0df0ae8cf30eddb8cde6 (patch)
tree5c878d9ed7c904135175b5111de72f1f43ed65cd /git-hooks/gerrit-bot
parent62a2168e83504eefec02598e995c87a1e83f3506 (diff)
downloadqtrepotools-cbddd3a5a6c9022b456c0df0ae8cf30eddb8cde6.tar.gz
move the work-in-progress detection to the bot itself
it obviously makes no sense when the sanitizer is executed locally. additionally, this allows us a different treatment of WIP reports: instead of giving a -2 sanity review, give a -2 code review. that way the change owner is not spammed by useless notifications (because the sanity review itself is positive, so the message is suppressed by the gerrit configuration). Change-Id: I10bc8f8f61673e75983dcb91310836d59c434483 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'git-hooks/gerrit-bot')
-rwxr-xr-xgit-hooks/gerrit-bot19
1 files changed, 17 insertions, 2 deletions
diff --git a/git-hooks/gerrit-bot b/git-hooks/gerrit-bot
index ef66fd1..6b4bb82 100755
--- a/git-hooks/gerrit-bot
+++ b/git-hooks/gerrit-bot
@@ -145,6 +145,7 @@ sub process_commit($$$$$)
$project =~ s,/$,,; # XXX Workaround QTQAINFRA-381
my ($score, $verdict);
my $message = "";
+ my $iswip = 0;
my @invite;
my $use_rest = 0;
if (defined($EXCLUDED_PROJECTS{$project}) || defined($EXCLUDED_PROJECTS{$project.":".$branch})) {
@@ -184,14 +185,18 @@ sub process_commit($$$$$)
$verbose and print "===== ".strftime("%c", localtime(time()))." ===== fetched change\n";
}
+ my $subject;
+
my @watches;
for my $w (@WATCHES) {
my $wp = $watch_projects{$w};
push @watches, $w if (!defined($wp) || $project =~ $wp);
}
if (@watches) {
- my @touched = `git diff-tree --name-only --no-commit-id --ignore-submodules -r -C --root $rev`;
+ my @touched = `git show --pretty=\%s --name-only --ignore-submodules -C $rev`;
chop(@touched);
+ $subject = shift @touched;
+ shift @touched; # empty line
for my $w (@watches) {
for my $file (@touched) {
if ($file =~ $watch_files{$w}) {
@@ -203,6 +208,15 @@ sub process_commit($$$$$)
}
}
+ if (!defined($subject)) {
+ $subject = `git show --pretty=\%s -s $rev`;
+ chop($subject);
+ }
+ if ($subject =~ /\b(?:WIP|Wip|wip(?!\/))\b|\*{3}|^(?:squash|fixup)! |^(.)\1*$/) {
+ $iswip = 1;
+ $message = "Apparently pushing a Work In Progress\n\n".$message;
+ }
+
my $worker = $WORKER;
$worker =~ s/\@SHA1\@/$rev/g;
open VERDICT, $worker." 2>&1 |" or die "cannot run worker: ".$!;
@@ -223,7 +237,7 @@ sub process_commit($$$$$)
$use_rest = 1;
$verdict = decode_json($verdict);
defined($verdict) or die "cannot decode verdict as JSON\n";
- $$verdict{labels} = { 'Sanity-Review' => $score };
+ $$verdict{labels} = { 'Sanity-Review' => $score, 'Code-Review' => ($iswip ? -2 : 0) };
}
} else {
if (length($verdict) > 20000) {
@@ -249,6 +263,7 @@ sub process_commit($$$$$)
# push @args, ("--project", $project);
push @args, ("--project", $orig_project); # XXX Workaround QTQAINFRA-381
push @args, ("--sanity-review", ($score > 0) ? "+".$score : $score);
+ push @args, ("--code-review", $iswip ? -2 : 0);
if (length($verdict)) {
$verdict =~ s/([\"\\\$\`])/\\$1/g; # ssh doesn`t properly quote the arguments for sh
$verdict =~ s/^\s+|\s+$//g;