Skip to content

Commit 4c741ab

Browse files
committed
GitLab: provide links for report
1 parent 38501d4 commit 4c741ab

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

lib/Synergy/Reactor/GitLab.pm

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -912,35 +912,55 @@ sub mr_report ($self, $who, $arg = {}) {
912912

913913
return Future->done unless @filed || @assigned || @selfies;
914914

915-
my $string = q{};
916-
917915
my $wipstr = sub ($mrs) {
918916
my $wip = grep {; $_->{title} =~ /^wip:/i } @$mrs;
919917
return $wip
920918
? (sprintf ' (of which %i %s WIP)', $wip, PL_V('is', $wip))
921919
: '';
922920
};
923921

922+
my $link = sub ($author, $assignee) {
923+
return sprintf '<%s/dashboard/merge_requests?scope=all&state=opened%s%s|GL>',
924+
$self->url_base,
925+
(defined $author ? "&author_username=$author" : ''),
926+
(defined $assignee ? "&assignee_username=$assignee" : ''),
927+
};
928+
929+
my @plain;
930+
my @slack;
931+
924932
if (@filed) {
925-
$string .= sprintf "\N{LOWER LEFT CRAYON} Merge %s waiting on others: %i%s\n",
933+
push @plain, sprintf "\N{LOWER LEFT CRAYON} Merge %s waiting on others: %i%s",
926934
PL_N('request', 0+@filed), 0+@filed, $wipstr->(\@filed);
935+
936+
my $url = $link->($who->username, undef);
937+
push @slack, $plain[-1] =~ s/ / $url /r;
927938
}
928939

929940
if (@assigned) {
930941
my $wip = grep {; $_->{title} =~ /^wip:/i } @filed;
931-
$string .= sprintf "\N{LOWER LEFT CRAYON} Merge %s to review: %i%s\n",
942+
push @plain, sprintf "\N{LOWER LEFT CRAYON} Merge %s to review: %i%s",
932943
PL_N('request', 0+@assigned), 0+@assigned, $wipstr->(\@assigned);
944+
945+
my $url = $link->(undef, $who->username);
946+
push @slack, $plain[-1] =~ s/ / $url /r;
933947
}
934948

935949
if (@selfies) {
936950
my $wip = grep {; $_->{title} =~ /^wip:/i } @filed;
937-
$string .= sprintf "\N{LOWER LEFT CRAYON} Self-assigned merge %s: %i%s\n",
951+
push @plain, sprintf "\N{LOWER LEFT CRAYON} Self-assigned merge %s: %i%s",
938952
PL_N('request', 0+@selfies), 0+@selfies, $wipstr->(\@selfies);
939-
}
940953

941-
chomp $string;
954+
my $url = $link->($who->username, $who->username);
955+
push @slack, $plain[-1] =~ s/ / $url /r;
956+
}
942957

943-
return Future->done([ $string, { slack => $string } ]);
958+
return Future->done([
959+
(join qq{\n}, @plain),
960+
{
961+
slack => (join qq{\n}, @slack),
962+
}
963+
]);
944964
});
945965
}
946966

0 commit comments

Comments
 (0)