Commit cbddd3a5 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen
Browse files

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: default avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
parent 62a2168e
Branches
No related merge requests found
Showing with 18 additions and 8 deletions
...@@ -145,6 +145,7 @@ sub process_commit($$$$$) ...@@ -145,6 +145,7 @@ sub process_commit($$$$$)
$project =~ s,/$,,; # XXX Workaround QTQAINFRA-381 $project =~ s,/$,,; # XXX Workaround QTQAINFRA-381
my ($score, $verdict); my ($score, $verdict);
my $message = ""; my $message = "";
my $iswip = 0;
my @invite; my @invite;
my $use_rest = 0; my $use_rest = 0;
if (defined($EXCLUDED_PROJECTS{$project}) || defined($EXCLUDED_PROJECTS{$project.":".$branch})) { if (defined($EXCLUDED_PROJECTS{$project}) || defined($EXCLUDED_PROJECTS{$project.":".$branch})) {
...@@ -184,14 +185,18 @@ sub process_commit($$$$$) ...@@ -184,14 +185,18 @@ sub process_commit($$$$$)
$verbose and print "===== ".strftime("%c", localtime(time()))." ===== fetched change\n"; $verbose and print "===== ".strftime("%c", localtime(time()))." ===== fetched change\n";
} }
my $subject;
my @watches; my @watches;
for my $w (@WATCHES) { for my $w (@WATCHES) {
my $wp = $watch_projects{$w}; my $wp = $watch_projects{$w};
push @watches, $w if (!defined($wp) || $project =~ $wp); push @watches, $w if (!defined($wp) || $project =~ $wp);
} }
if (@watches) { 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); chop(@touched);
$subject = shift @touched;
shift @touched; # empty line
for my $w (@watches) { for my $w (@watches) {
for my $file (@touched) { for my $file (@touched) {
if ($file =~ $watch_files{$w}) { if ($file =~ $watch_files{$w}) {
...@@ -203,6 +208,15 @@ sub process_commit($$$$$) ...@@ -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; my $worker = $WORKER;
$worker =~ s/\@SHA1\@/$rev/g; $worker =~ s/\@SHA1\@/$rev/g;
open VERDICT, $worker." 2>&1 |" or die "cannot run worker: ".$!; open VERDICT, $worker." 2>&1 |" or die "cannot run worker: ".$!;
...@@ -223,7 +237,7 @@ sub process_commit($$$$$) ...@@ -223,7 +237,7 @@ sub process_commit($$$$$)
$use_rest = 1; $use_rest = 1;
$verdict = decode_json($verdict); $verdict = decode_json($verdict);
defined($verdict) or die "cannot decode verdict as JSON\n"; 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 { } else {
if (length($verdict) > 20000) { if (length($verdict) > 20000) {
...@@ -249,6 +263,7 @@ sub process_commit($$$$$) ...@@ -249,6 +263,7 @@ sub process_commit($$$$$)
# push @args, ("--project", $project); # push @args, ("--project", $project);
push @args, ("--project", $orig_project); # XXX Workaround QTQAINFRA-381 push @args, ("--project", $orig_project); # XXX Workaround QTQAINFRA-381
push @args, ("--sanity-review", ($score > 0) ? "+".$score : $score); push @args, ("--sanity-review", ($score > 0) ? "+".$score : $score);
push @args, ("--code-review", $iswip ? -2 : 0);
if (length($verdict)) { if (length($verdict)) {
$verdict =~ s/([\"\\\$\`])/\\$1/g; # ssh doesn`t properly quote the arguments for sh $verdict =~ s/([\"\\\$\`])/\\$1/g; # ssh doesn`t properly quote the arguments for sh
$verdict =~ s/^\s+|\s+$//g; $verdict =~ s/^\s+|\s+$//g;
......
...@@ -39,6 +39,4 @@ if test -L "$me"; then ...@@ -39,6 +39,4 @@ if test -L "$me"; then
fi fi
sha1=${1-HEAD} # just for debugging sha1=${1-HEAD} # just for debugging
GIT_PUSH=${GIT_PUSH+$GIT_PUSH,}wip # this check makes totally no sense locally
export GIT_PUSH
exec `dirname "$me"`/sanitize-commit $sha1 strict >&2 exec `dirname "$me"`/sanitize-commit $sha1 strict >&2
...@@ -106,7 +106,6 @@ use constant { ...@@ -106,7 +106,6 @@ use constant {
my $clike = 0; my $clike = 0;
my $qmake = 0; my $qmake = 0;
my $iswip = defined($cfg{wip});
my $badrev = 0; my $badrev = 0;
my $badsign = 0; my $badsign = 0;
my $badid = defined($cfg{changeid}); my $badid = defined($cfg{changeid});
...@@ -287,9 +286,7 @@ while (<MSG>) { ...@@ -287,9 +286,7 @@ while (<MSG>) {
if (/\bQT[A-Z]+-\d+\b/) { if (/\bQT[A-Z]+-\d+\b/) {
complain_cln("Bug reference in summary", "log"); complain_cln("Bug reference in summary", "log");
} }
if (!$iswip && $parents < 2 && /\b(?:WIP|Wip|wip(?!\/))\b|\*{3}|^(?:squash|fixup)! |^(.)\1*$/) { if (!$badlog && length($_) < 7) {
complain_cln("Apparently pushing a Work In Progress", "wip", 1);
} elsif (!$iswip && !$badlog && length($_) < 7) {
complain_cln("Summary is too short", "log"); complain_cln("Summary is too short", "log");
} elsif (!$badlog && !$revert1 && length($_) > 120) { } elsif (!$badlog && !$revert1 && length($_) > 120) {
complain_cln("Summary is excessively long", "log"); complain_cln("Summary is excessively long", "log");
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment