line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::BitBucketCli::Command::PullRequests; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2018-06-07 08:23:20 |
4
|
|
|
|
|
|
|
# Create by: Ivan Wills |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4202
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
10
|
1
|
|
|
1
|
|
262
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
57
|
|
11
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
57
|
|
12
|
1
|
|
|
1
|
|
6
|
use Data::Dumper qw/Dumper/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
56
|
|
13
|
1
|
|
|
1
|
|
5
|
use English qw/ -no_match_vars /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
extends 'App::BitBucketCli'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = 0.008; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub options { |
20
|
0
|
|
|
0
|
1
|
|
return [qw/ |
21
|
|
|
|
|
|
|
colors|c=s% |
22
|
|
|
|
|
|
|
force|f! |
23
|
|
|
|
|
|
|
author|a=s |
24
|
|
|
|
|
|
|
emails|e=s |
25
|
|
|
|
|
|
|
to_branch|to-branch|t=s |
26
|
|
|
|
|
|
|
from_branch|from-branch|f=s |
27
|
|
|
|
|
|
|
title|T=s |
28
|
|
|
|
|
|
|
state|S=s |
29
|
|
|
|
|
|
|
long|l |
30
|
|
|
|
|
|
|
project|p=s |
31
|
|
|
|
|
|
|
participant|P=s |
32
|
|
|
|
|
|
|
regexp|R |
33
|
|
|
|
|
|
|
remote|m=s |
34
|
|
|
|
|
|
|
repository|r=s |
35
|
|
|
|
|
|
|
sleep|s=i |
36
|
|
|
|
|
|
|
/] |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub pull_requests { |
40
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my @pull_requests = sort { |
43
|
0
|
|
|
|
|
|
lc $a->id cmp lc $b->id; |
44
|
|
|
|
|
|
|
} |
45
|
0
|
|
0
|
|
|
|
$self->core->pull_requests($self->opt->{project}, $self->opt->{repository}, $self->opt->{state} || 'OPEN'); |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my @prs; |
48
|
|
|
|
|
|
|
my %max; |
49
|
0
|
|
|
|
|
|
my $author = $self->opt->author(); |
50
|
0
|
|
|
|
|
|
my $to_branch = $self->opt->to_branch(); |
51
|
0
|
|
|
|
|
|
my $from_branch = $self->opt->from_branch(); |
52
|
0
|
|
|
|
|
|
my $title = $self->opt->title(); |
53
|
0
|
|
|
|
|
|
my $emails = $self->opt->emails(); |
54
|
0
|
|
|
|
|
|
my $participant = $self->opt->participant(); |
55
|
0
|
|
|
|
|
|
for my $pull_request (@pull_requests) { |
56
|
0
|
0
|
0
|
|
|
|
next if $author && $pull_request->author->{user}{displayName} !~ /$author/; |
57
|
0
|
0
|
0
|
|
|
|
next if $to_branch && $pull_request->toRef->{displayId} !~ /$to_branch/; |
58
|
0
|
0
|
0
|
|
|
|
next if $from_branch && $pull_request->fromRef->{displayId} !~ /$from_branch/; |
59
|
0
|
0
|
0
|
|
|
|
next if $title && $pull_request->title !~ /$title/; |
60
|
0
|
0
|
0
|
|
|
|
next if $emails && ! grep { /$emails/ } @{ $pull_request->emails }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
61
|
0
|
0
|
0
|
|
|
|
next if $participant && ! grep { $_->{user}{displayName} =~ /$participant/ } @{ $pull_request->participants }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
0
|
|
0
|
|
|
|
my $tasks = eval { $pull_request->{openTasks}->[0] } || 0; |
64
|
|
|
|
|
|
|
push @prs, { |
65
|
|
|
|
|
|
|
id => $pull_request->id, |
66
|
|
|
|
|
|
|
title => $pull_request->title, |
67
|
|
|
|
|
|
|
author => $pull_request->author->{user}{displayName}, |
68
|
|
|
|
|
|
|
from => $pull_request->fromRef->{displayId}, |
69
|
|
|
|
|
|
|
to => $pull_request->toRef->{displayId}, |
70
|
0
|
|
|
|
|
|
emails => $pull_request->emails, |
71
|
|
|
|
|
|
|
tasks => $tasks, |
72
|
|
|
|
|
|
|
}; |
73
|
0
|
|
|
|
|
|
chomp $prs[-1]{title}; |
74
|
0
|
|
|
|
|
|
for my $key (keys %{ $prs[-1] }) { |
|
0
|
|
|
|
|
|
|
75
|
0
|
0
|
0
|
|
|
|
$max{$key} = length $prs[-1]{$key} if ! $max{$key} || $max{$key} < length $prs[-1]{$key}; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
for my $pr (@prs) { |
80
|
0
|
|
|
|
|
|
printf "%-$max{id}s ", $pr->{id}; |
81
|
0
|
|
|
|
|
|
printf "%-$max{author}s ", $pr->{author}; |
82
|
0
|
|
|
|
|
|
printf "%-$max{tasks}s ", $pr->{tasks}; |
83
|
0
|
|
|
|
|
|
print "$pr->{title}\n"; |
84
|
0
|
0
|
|
|
|
|
if ( $self->opt->long ) { |
85
|
0
|
|
|
|
|
|
print ' ', ( join ', ', @{ $pr->{emails} } ), "\n"; |
|
0
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 NAME |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
App::BitBucketCli::Command::PullRequests - Show the pull requests of a repository |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 VERSION |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This documentation refers to App::BitBucketCli::Command::PullRequests version 0.008 |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 SYNOPSIS |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
bb-cli pull-requests [options] |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
OPTIONS: |
107
|
|
|
|
|
|
|
-c --colors[=]str Change colours used specified as key=value |
108
|
|
|
|
|
|
|
eg --colors disabled=grey22 |
109
|
|
|
|
|
|
|
current colour names aborted, disabled and notbuilt |
110
|
|
|
|
|
|
|
-f --force Force action |
111
|
|
|
|
|
|
|
-l --long Show long form data if possible |
112
|
|
|
|
|
|
|
-p --project[=]str |
113
|
|
|
|
|
|
|
For commands that need a project name this is the name to use |
114
|
|
|
|
|
|
|
-R --recipient[=]str |
115
|
|
|
|
|
|
|
?? |
116
|
|
|
|
|
|
|
-R --regexp[=]str ?? |
117
|
|
|
|
|
|
|
-m --remote[=]str ?? |
118
|
|
|
|
|
|
|
-r --repository[=]str |
119
|
|
|
|
|
|
|
For commands that work on repositories this contains the repository |
120
|
|
|
|
|
|
|
-s --sleep[=]seconds |
121
|
|
|
|
|
|
|
?? |
122
|
|
|
|
|
|
|
-t --test ?? |
123
|
|
|
|
|
|
|
-a --author[=]regex |
124
|
|
|
|
|
|
|
Show only pull requests by this author |
125
|
|
|
|
|
|
|
-e --emails[=]regex |
126
|
|
|
|
|
|
|
Show only pull requests involving anyone with an email |
127
|
|
|
|
|
|
|
matching matching this regex. |
128
|
|
|
|
|
|
|
-P --participant[=]regex |
129
|
|
|
|
|
|
|
Show only pull requests with participants matching this regex |
130
|
|
|
|
|
|
|
-t --to-branch[=]regex |
131
|
|
|
|
|
|
|
Show only pull requests to this branch |
132
|
|
|
|
|
|
|
-f --from-branch[=]rege |
133
|
|
|
|
|
|
|
Show only pull requests from this branchx |
134
|
|
|
|
|
|
|
-T --title[=]regex |
135
|
|
|
|
|
|
|
Show only pull requests matching this title |
136
|
|
|
|
|
|
|
-S --state[=](OPEN|MERGED|DECLINED|ALL) |
137
|
|
|
|
|
|
|
Show pull requests of this type (Default OPEN) |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
CONFIGURATION: |
140
|
|
|
|
|
|
|
-h --host[=]str Specify the Stash/Bitbucket Servier host name |
141
|
|
|
|
|
|
|
-P --password[=]str |
142
|
|
|
|
|
|
|
The password to connect to the server as |
143
|
|
|
|
|
|
|
-u --username[=]str |
144
|
|
|
|
|
|
|
The username to connect to the server as |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
-v --verbose Show more detailed option |
147
|
|
|
|
|
|
|
--version Prints the version information |
148
|
|
|
|
|
|
|
--help Prints this help information |
149
|
|
|
|
|
|
|
--man Prints the full documentation for bb-cli |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 DESCRIPTION |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head2 C<options ()> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Returns the command line options |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 C<pull_requests ()> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
There are no known bugs in this module. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Please report problems to Ivan Wills (ivan.wills@gmail.com). |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Patches are welcome. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 AUTHOR |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Ivan Wills - (ivan.wills@gmail.com) |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Copyright (c) 2018 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). |
184
|
|
|
|
|
|
|
All rights reserved. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
187
|
|
|
|
|
|
|
the same terms as Perl itself. See L<perlartistic>. This program is |
188
|
|
|
|
|
|
|
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
189
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
190
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=cut |