tiistai 25. kesäkuuta 2013

trivial-rebase.py in Gerrit 2.6, fixing "trivial_rebase.py: error: Incomplete arguments"

Trivial rebase detection had some changes when Gerrit 2.6.0 was released, and my previous patchsets-created hook didn't work anymore. In logs, there was

[2013-06-25 12:05:33,916] INFO com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output: trivial_rebase.py: error: Incomplete arguments

To fix this, I modified my patchset-created hook to following (original came from some discussion list, and I was extremely stupid and didn't write down where I got it :( ):

#!/usr/bin/perl

use strict;
use warnings;
use Getopt::Long;

my $gerritHome="/home/gerrit2";
my $gerritRoot=$gerritHome."/review_site";
my $hookDir=$gerritHome."/scripts";

my $change;
my $project;
my $commit;
my $patchset;
my $changeurl;
# Not really needed, but without these error_log will have entries like
# INFO com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output: Unknown option:
my $branch;
my $uploader;
my $isdraft;

my $result = GetOptions("change=s" => \$change,
"project=s" => \$project,
"branch=s" => \$branch,
"commit=s" => \$commit,
"patchset=s" => \$patchset,
"change-url=s" => \$changeurl,
"is-draft=s" => \$isdraft,
"uploader=s" => \$uploader);

system($hookDir."/trivial_rebase.py",
"--project", $project,
"--commit", $commit,
"--patchset", $patchset,
"--change-url", $changeurl,
"--private-key-path", $gerritRoot."/etc/ssh_host_dsa_key");

To use this, trivial_rebase.py must be in /home/gerrit2/scripts/trivial_rebase.py and it must be executable by gerrit2 user.

Ei kommentteja :

Lähetä kommentti