Include names of committers in HipChat notifications

[?]
Jul 2, 2013, 11:54 AM
NB2VOKIROXTIIIXKPHFHCGO236KPKXWYDSWUWVJF3XBRHRMUIQ4AC

Dependencies

  • [2] JAH3UPWA Support revision control systems via plugins
  • [3] ZDEHAFHV Add a plugin for HipChat notification
  • [4] BLVQGJ4L Use OO-style plugins
  • [5] J5UVLXOK * Start of a basic Catalyst web interface.
  • [6] NILMMFMY Respect X-Request-Base header coming from a frontend proxy.
  • [7] WQXF2T3D hydra-evaluator: Don't require $HYDRA_CONFIG
  • [8] OVR2RWBI hydra-evaluator: Always pick the jobset that hasn't been evaluated longest
  • [9] 5EQYVRWE Add a plugin mechanism
  • [10] QUTWJR7P * Include more info in notification emails.
  • [*] 7YBYT2LQ
  • [*] N22GPKYT * Put info about logs / build products in the DB.

Change contents

  • edit in src/lib/Hydra/Plugin/GitInput.pm at line 14
    [2.5146][2.5146:5244]()
    sub fetchInput {
    my ($self, $type, $name, $value) = @_;
    return undef if $type ne "git";
  • replacement in src/lib/Hydra/Plugin/GitInput.pm at line 15
    [2.5245][2.5245:5421]()
    (my $uri, my $branch, my $deepClone) = split ' ', $value;
    $branch = defined $branch ? $branch : "master";
    my $timestamp = time;
    my $sha256;
    my $storePath;
    [2.5245]
    [2.5421]
    # Clone or update a branch of a repository into our SCM cache.
    sub _cloneRepo {
    my ($self, $uri, $branch, $deepClone) = @_;
  • replacement in src/lib/Hydra/Plugin/GitInput.pm at line 33
    [2.6030][2.6030:6190]()
    # 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
    [2.6030]
    [2.6190]
    # 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
  • edit in src/lib/Hydra/Plugin/GitInput.pm at line 42
    [2.6545][2.6545:6963]()
    ($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";
  • edit in src/lib/Hydra/Plugin/GitInput.pm at line 58
    [2.7738]
    [2.7738]
    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]+$/;
  • edit in src/lib/Hydra/Plugin/GitInput.pm at line 91
    [2.7739]
    [2.7739]
    my $ref = "refs/heads/$branch";
  • edit in src/lib/Hydra/Plugin/GitInput.pm at line 164
    [2.10644]
    [2.10644]
    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;
    }
  • edit in src/lib/Hydra/Plugin/HipChatNotification.pm at line 37
    [3.1278]
    [3.1278]
    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;
  • edit in src/lib/Hydra/Plugin/HipChatNotification.pm at line 55
    [3.1279]
    [3.1279]
    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++;
    }
    }
    }
  • edit in src/lib/Hydra/Plugin/HipChatNotification.pm at line 86
    [3.2197]
    [3.2197]
    if (scalar keys %authors > 0) {
    # FIXME: HTML escaping
    my @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]);
    }
  • edit in src/lib/Hydra/Plugin/HipChatNotification.pm at line 95
    [3.2274]
    [3.2274]
    next;
  • replacement in src/lib/Hydra/Plugin.pm at line 10
    [4.354][4.354:415]()
    my $self = { db => $args{db}, config => $args{config} };
    [4.354]
    [4.415]
    my $self = { db => $args{db}, config => $args{config}, plugins => $args{plugins} };
  • edit in src/lib/Hydra/Plugin.pm at line 13
    [4.458]
    [4.458]
    }
    sub instantiate {
    my ($class, %args) = @_;
    my $plugins = [];
    $args{plugins} = $plugins;
    push @$plugins, $class->plugins(%args);
    return @$plugins;
  • edit in src/lib/Hydra/Plugin.pm at line 45
    [2.19581]
    [4.6305]
    # Get the commits to repository ‘$value’ between revisions ‘$rev1’ and
    # ‘$rev2’. Each commit should be a hash ‘{ revision = "..."; author =
    # "..."; email = "..."; }’.
    sub getCommits {
    my ($self, $type, $value, $rev1, $rev2) = @_;
    return [];
    }
  • replacement in src/lib/Hydra.pm at line 95
    [2.19755][2.19755:19849]()
    $plugins = [Hydra::Plugin->plugins(db => $class->model('DB'), config => $class->config)];
    [2.19755]
    [2.19849]
    $plugins = [Hydra::Plugin->instantiate(db => $class->model('DB'), config => $class->config)];
  • replacement in src/script/hydra-build at line 20
    [4.527][4.527:595]()
    my @plugins = Hydra::Plugin->plugins(db => $db, config => $config);
    [4.527]
    [4.1062]
    my @plugins = Hydra::Plugin->instantiate(db => $db, config => $config);
  • replacement in src/script/hydra-evaluator at line 24
    [4.1][2.19874:19944]()
    my $plugins = [Hydra::Plugin->plugins(db => $db, config => $config)];
    [4.1]
    [2.19944]
    my $plugins = [Hydra::Plugin->instantiate(db => $db, config => $config)];