Factor a getResponsibleAuthors helper out of the HipChatNotification

[?]
Oct 7, 2013, 1:44 PM
BEFHUCGNM3FRVAEDTOSSBRKOUNRC2IIYKEIVIVREUBGAEORVRQJAC

Dependencies

  • [2] RPTSGIRC Eliminate duplicate getPreviousBuild functions
  • [3] 7OS2VAOO Fix Hipchat notification
  • [4] IBW53PUC HipChat notification: add support for Mercurial inputs for determining who might have broken the build.
  • [5] ZO457GFG HipChat notification: do not include latest commits of all inputs in 'who-broke-the-build' list. Use only committers from inputs that have actually changed since previous build.
  • [6] NB2VOKIR Include names of committers in HipChat notifications
  • [7] ZDEHAFHV Add a plugin for HipChat notification
  • [8] H6D6OVYK Get rid of a warning in the HipChat plugin
  • [*] LBNVQXUB * Build the /build stuff in a separate controller.
  • [*] CS7T2XFI
  • [*] PCKLFRT5 Support push notification of repository changes

Change contents

  • edit in src/lib/Hydra/Helper/CatalystUtils.pm at line 30
    [2.144]
    [11.180]
    getResponsibleAuthors
  • edit in src/lib/Hydra/Helper/CatalystUtils.pm at line 252
    [12.1816]
    [11.367]
    # Determine who broke/fixed the build.
    sub getResponsibleAuthors {
    my ($build, $plugins) = @_;
  • edit in src/lib/Hydra/Helper/CatalystUtils.pm at line 258
    [11.368]
    [11.368]
    my $prevBuild = getPreviousBuild($build);
  • edit in src/lib/Hydra/Helper/CatalystUtils.pm at line 260
    [11.369]
    [10.3787]
    my $nrCommits = 0;
    my %authors;
    if ($prevBuild) {
    foreach my $curInput ($build->buildinputs_builds) {
    next unless ($curInput->type eq "git" || $curInput->type eq "hg");
    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;
    next if $curInput->revision eq $prevInput->revision;
    my @commits;
    foreach my $plugin (@{$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++;
    }
    }
    }
    return (\%authors, $nrCommits);
    }
  • edit in src/lib/Hydra/Plugin/HipChatNotification.pm at line 42
    [6.2076][6.2076:2200](),[6.2200][4.0:79](),[4.79][6.2250:2502](),[6.2250][6.2250:2502](),[6.2502][5.0:65](),[5.65][6.1278:1279](),[6.2502][6.1278:1279](),[6.1278][6.1278:1279](),[6.1279][6.2503:2728]()
    my $nrCommits = 0;
    my %authors;
    if ($prevBuild) {
    foreach my $curInput ($build->buildinputs_builds) {
    next unless ($curInput->type eq "git" || $curInput->type eq "hg");
    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;
    next if $curInput->revision eq $prevInput->revision;
    my @commits;
    foreach my $plugin (@{$self->{plugins}}) {
    push @commits, @{$plugin->getCommits($curInput->type, $curInput->uri, $prevInput->revision, $curInput->revision)};
    }
  • replacement in src/lib/Hydra/Plugin/HipChatNotification.pm at line 43
    [6.2729][6.2729:2773](),[6.2773][3.0:76](),[3.76][6.2848:2972](),[6.2848][6.2848:2972]()
    foreach my $commit (@commits) {
    #print STDERR "$commit->{revision} by $commit->{author}\n";
    $authors{$commit->{author}} = $commit->{email};
    $nrCommits++;
    }
    }
    }
    [6.2729]
    [6.2972]
    my ($authors, $nrCommits) = getResponsibleAuthors($build, $self->{plugins});
  • replacement in src/lib/Hydra/Plugin/HipChatNotification.pm at line 63
    [6.2197][6.2974:3014]()
    if (scalar keys %authors > 0) {
    [6.2197]
    [6.3014]
    if (scalar keys %{$authors} > 0) {
  • replacement in src/lib/Hydra/Plugin/HipChatNotification.pm at line 65
    [6.3049][6.3049:3138]()
    my @x = map { "<a href='mailto:$authors{$_}'>$_</a>" } (sort keys %authors);
    [6.3049]
    [6.3138]
    my @x = map { "<a href='mailto:$authors->{$_}'>$_</a>" } (sort keys %{$authors});