diff options
-rwxr-xr-x | git-hooks/gerrit-bot | 33 |
1 files changed, 1 insertions, 32 deletions
diff --git a/git-hooks/gerrit-bot b/git-hooks/gerrit-bot index 4bd24b7..6697d91 100755 --- a/git-hooks/gerrit-bot +++ b/git-hooks/gerrit-bot @@ -246,38 +246,7 @@ sub process_commit($$$$$) sub do_move($$$) { - my ($chg, $author, $target) = @_; - my $branch = $$chg{'branch'}; - if ($target eq $branch) { - return "The change already targets $branch"; - } - # FIXME: this doesn't work, as for some reason the event stream does not include the status. - #my %allowed_status = ('NEW' => 1, 'DEFERRED' => 1, 'DRAFT' => 1, 'ABANDONED' => 1); - #my $status = $$chg{'status'}; - #return "$status changes cannot be moved" if (!$allowed_status{$status}); - my $project = $$chg{'project'}; - my $id = $$chg{'id'}; - # First, check there's no such review on that branch already - my $query = "project:$project change:$id branch:$target"; - open(my $qry, "-|", @gerrit, "query", "--format", "JSON", $query) or die "cannot run ssh: ".$!; - while (<$qry>) { - my $review = decode_json($_); - defined($review) or die "cannot decode JSON string '".chomp($_)."'\n"; - if (my $url = $$review{'url'}) { - return "Cannot move: Conflicting change $url - please ask a Gerrit admin for help."; - } - } - close $qry; - # Only allow the change owner to execute move - if ($$author{'username'} ne $$chg{'owner'}{'username'}) { - return "Only the owner is allowed to move a change"; - } - my $number = $$chg{'number'}; - open(my $retarget, "gerrit_retarget_changes x $target $number 2>&1 |") - or die "Cannot run gerrit_retarget_changes: ".$!; - my @output = <$retarget>; - return "Moved from $branch" if (close($retarget)); - return ($! ? "Failed to move ($!)\n" : "Move rejected ($?)\n") . join(' ', @output); + return "Please use the menu in the top right corner 'Move change' instead of this bot."; } sub process_move($$$) { |