HipChat notification: add support for Mercurial inputs for determining who might have broken the build.
This commit is contained in:
parent
96e987bbfa
commit
90eedcf256
|
@ -45,7 +45,7 @@ sub buildFinished {
|
||||||
|
|
||||||
if ($prevBuild) {
|
if ($prevBuild) {
|
||||||
foreach my $curInput ($build->buildinputs_builds) {
|
foreach my $curInput ($build->buildinputs_builds) {
|
||||||
next unless $curInput->type eq "git";
|
next unless ($curInput->type eq "git" || $curInput->type eq "hg");
|
||||||
my $prevInput = $prevBuild->buildinputs_builds->find({ name => $curInput->name });
|
my $prevInput = $prevBuild->buildinputs_builds->find({ name => $curInput->name });
|
||||||
next unless defined $prevInput;
|
next unless defined $prevInput;
|
||||||
|
|
||||||
|
|
|
@ -12,21 +12,33 @@ sub supportedInputTypes {
|
||||||
$inputTypes->{'hg'} = 'Mercurial checkout';
|
$inputTypes->{'hg'} = 'Mercurial checkout';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub _parseValue {
|
||||||
|
my ($value) = @_;
|
||||||
|
(my $uri, my $id) = split ' ', $value;
|
||||||
|
$id = defined $id ? $id : "default";
|
||||||
|
return ($uri, $id);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub _clonePath {
|
||||||
|
my ($uri) = @_;
|
||||||
|
my $cacheDir = getSCMCacheDir . "/hg";
|
||||||
|
mkpath($cacheDir);
|
||||||
|
return $cacheDir . "/" . sha256_hex($uri);
|
||||||
|
}
|
||||||
|
|
||||||
sub fetchInput {
|
sub fetchInput {
|
||||||
my ($self, $type, $name, $value) = @_;
|
my ($self, $type, $name, $value) = @_;
|
||||||
|
|
||||||
return undef if $type ne "hg";
|
return undef if $type ne "hg";
|
||||||
|
|
||||||
(my $uri, my $id) = split ' ', $value;
|
(my $uri, my $id) = _parseValue($value);
|
||||||
$id = defined $id ? $id : "default";
|
$id = defined $id ? $id : "default";
|
||||||
|
|
||||||
# init local hg clone
|
# init local hg clone
|
||||||
|
|
||||||
my $stdout = ""; my $stderr = "";
|
my $stdout = ""; my $stderr = "";
|
||||||
|
|
||||||
my $cacheDir = getSCMCacheDir . "/hg";
|
my $clonePath = _clonePath($uri);
|
||||||
mkpath($cacheDir);
|
|
||||||
my $clonePath = $cacheDir . "/" . sha256_hex($uri);
|
|
||||||
|
|
||||||
if (! -d $clonePath) {
|
if (! -d $clonePath) {
|
||||||
(my $res, $stdout, $stderr) = captureStdoutStderr(600,
|
(my $res, $stdout, $stderr) = captureStdoutStderr(600,
|
||||||
|
@ -85,4 +97,32 @@ sub fetchInput {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub getCommits {
|
||||||
|
my ($self, $type, $value, $rev1, $rev2) = @_;
|
||||||
|
return [] if $type ne "hg";
|
||||||
|
|
||||||
|
return [] unless $rev1 =~ /^[0-9a-f]+$/;
|
||||||
|
return [] unless $rev2 =~ /^[0-9a-f]+$/;
|
||||||
|
|
||||||
|
my ($uri, $id) = _parseValue($value);
|
||||||
|
|
||||||
|
my $clonePath = _clonePath($uri);
|
||||||
|
chdir $clonePath or die $!;
|
||||||
|
|
||||||
|
my $out;
|
||||||
|
IPC::Run::run(["hg", "log", "--template", "{node|short}\t{author|person}\t{author|email}\n", "-r", "$rev1:$rev2", $clonePath], \undef, \$out)
|
||||||
|
or die "cannot get mercurial logs: $?";
|
||||||
|
|
||||||
|
my $res = [];
|
||||||
|
foreach my $line (split /\n/, $out) {
|
||||||
|
if ($line ne "") {
|
||||||
|
my ($revision, $author, $email) = split "\t", $line;
|
||||||
|
push @$res, { revision => $revision, author => $author, email => $email };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
Loading…
Reference in a new issue