HipChat notification messages now say which committers were responsible, e.g.
Job patchelf:trunk:tarball: Failed, probably due to 2 commits by Eelco Dolstra
NB2VOKIROXTIIIXKPHFHCGO236KPKXWYDSWUWVJF3XBRHRMUIQ4AC JAH3UPWAVSHXIPNGL6PROQPZBYZHPJNFONWBDZX4HCX646USZXUQC ZDEHAFHV3PGIMALKSSPZTKHWMY3EVGYQJPH35DXVJ7OL5NXPY7WAC BLVQGJ4LITFCIR3KAUX3GWAHMYH3XXFC4BDXUSXUVEJFEJ7IMM4AC 5EQYVRWECBDJORGI5DRIOUEJXSXMRCQNT2562BM4Z4U52LT7JUHAC J5UVLXOK6EDIL5I7VKWH4V2QDS4DPD7FHRK6XBWSXFRQS4JKXFZQC 7YBYT2LQML2PKEO6UO4444AGSASS664UCDXW2YO3ALB7THQHCEBQC QUTWJR7PQZ3DBPC4G2AFXOKPPGFZQLE5RLXHAOFTLMXIT2QPF4TQC OVR2RWBIUXNW2XSG63KFL2S3Q7UVTLHOEYO3573LZBY7AMLUKKTQC N22GPKYTOLZLBGTGDATQDVZ4R5APZEAOIA7L32X4UXBH4XNI7MWAC (my $uri, my $branch, my $deepClone) = split ' ', $value;$branch = defined $branch ? $branch : "master";my $timestamp = time;my $sha256;my $storePath;
# Clone or update a branch of a repository into our SCM cache.sub _cloneRepo {my ($self, $uri, $branch, $deepClone) = @_;
# This command force the update of the local branch to be in the same as# the remote branch for whatever the repository state is. This command mirror
# This command forces the update of the local branch to be in the same as# the remote branch for whatever the repository state is. This command mirrors
($res, $stdout, $stderr) = captureStdoutStderr(600,("git", "rev-parse", "$branch"));die "error getting revision number of Git branch '$branch' at `$uri':\n$stderr" if $res;my ($revision) = split /\n/, $stdout;die "error getting a well-formated revision number of Git branch '$branch' at `$uri':\n$stdout"unless $revision =~ /^[0-9a-fA-F]+$/;my $ref = "refs/heads/$branch";
return $clonePath;}sub _parseValue {my ($value) = @_;(my $uri, my $branch, my $deepClone) = split ' ', $value;$branch = defined $branch ? $branch : "master";return ($uri, $branch, $deepClone);}sub fetchInput {my ($self, $type, $name, $value) = @_;return undef if $type ne "git";my ($uri, $branch, $deepClone) = _parseValue($value);my $clonePath = $self->_cloneRepo($uri, $branch, $deepClone);my $timestamp = time;my $sha256;my $storePath;my ($res, $stdout, $stderr) = captureStdoutStderr(600,("git", "rev-parse", "$branch"));die "error getting revision number of Git branch '$branch' at `$uri':\n$stderr" if $res;my ($revision) = split /\n/, $stdout;die "error getting a well-formated revision number of Git branch '$branch' at `$uri':\n$stdout"unless $revision =~ /^[0-9a-fA-F]+$/;
sub getCommits {my ($self, $type, $value, $rev1, $rev2) = @_;return [] if $type ne "git";return [] unless $rev1 =~ /^[0-9a-f]+$/;return [] unless $rev2 =~ /^[0-9a-f]+$/;my ($uri, $branch, $deepClone) = _parseValue($value);my $clonePath = $self->_cloneRepo($uri, $branch, $deepClone);my $out;IPC::Run::run(["git", "log", "--pretty=format:%H%x09%an%x09%ae%x09%at", "$rev1..$rev2"], \undef, \$out)or die "cannot get git logs: $?";my $res = [];foreach my $line (split /\n/, $out) {my ($revision, $author, $email, $date) = split "\t", $line;push @$res, { revision => $revision, author => $author, email => $email };}return $res;}
return if scalar keys %rooms == 0;# Determine who broke/fixed the build.my $prevBuild = getPreviousBuild($build);my $nrCommits = 0;my %authors;if ($prevBuild) {foreach my $curInput ($build->buildinputs_builds) {next unless $curInput->type eq "git";my $prevInput = $prevBuild->buildinputs_builds->find({ name => $curInput->name });next unless defined $prevInput;next if $curInput->type ne $prevInput->type;next if $curInput->uri ne $prevInput->uri;
my @commits;foreach my $plugin (@{$self->{plugins}}) {push @commits, @{$plugin->getCommits($curInput->type, $curInput->uri, $prevInput->revision, $curInput->revision)};}foreach my $commit (@commits) {print STDERR "$commit->{revision} by $commit->{author}\n";$authors{$commit->{author}} = $commit->{email};$nrCommits++;}}}
if (scalar keys %authors > 0) {# FIXME: HTML escapingmy @x = map { "<a href='mailto:$authors{$_}'>$_</a>" } (sort keys %authors);$msg .= ", likely due to ";$msg .= "$nrCommits commits by " if $nrCommits > 1;$msg .= join(" or ", scalar @x > 1 ? join(", ", @x[0..scalar @x - 2]) : (), $x[-1]);}