line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
use strict; |
2
|
1
|
|
|
1
|
|
797
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
3
|
1
|
|
|
1
|
|
6
|
use 5.024; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
4
|
1
|
|
|
1
|
|
21
|
|
|
1
|
|
|
|
|
4
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: App::TimeTracker GitHub plugin |
6
|
|
|
|
|
|
|
use App::TimeTracker::Utils qw(error_message warning_message); |
7
|
1
|
|
|
1
|
|
605
|
|
|
1
|
|
|
|
|
8951
|
|
|
1
|
|
|
|
|
60
|
|
8
|
|
|
|
|
|
|
our $VERSION = "1.002"; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Moose::Role; |
11
|
1
|
|
|
1
|
|
398
|
use Pithub; |
|
1
|
|
|
|
|
390939
|
|
|
1
|
|
|
|
|
5
|
|
12
|
1
|
|
|
1
|
|
5341
|
|
|
1
|
|
|
|
|
246701
|
|
|
1
|
|
|
|
|
540
|
|
13
|
|
|
|
|
|
|
has 'issue' => ( |
14
|
|
|
|
|
|
|
is => 'rw', |
15
|
|
|
|
|
|
|
isa => 'Str', |
16
|
|
|
|
|
|
|
documentation => 'github issue', |
17
|
|
|
|
|
|
|
predicate => 'has_issue' |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'github_client' => ( |
21
|
|
|
|
|
|
|
is => 'rw', |
22
|
|
|
|
|
|
|
isa => 'Maybe[Pithub]', |
23
|
|
|
|
|
|
|
lazy_build => 1, |
24
|
|
|
|
|
|
|
traits => ['NoGetopt'], |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $self = shift; |
28
|
|
|
|
|
|
|
my $config = $self->config->{github}; |
29
|
0
|
|
|
0
|
|
|
|
30
|
0
|
|
|
|
|
|
my %args; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
# required |
33
|
|
|
|
|
|
|
for my $fld (qw(user repo token)) { |
34
|
|
|
|
|
|
|
error_message( "Please configure github." . $fld . ". in your TimeTracker config" ) |
35
|
0
|
|
|
|
|
|
unless $config->{$fld}; |
36
|
|
|
|
|
|
|
$args{$fld} = $config->{$fld}; |
37
|
0
|
0
|
|
|
|
|
} |
38
|
0
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# optional |
40
|
|
|
|
|
|
|
$args{api_uri} = $config->{api_uri} if $config->{api_uri}; |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
if ( $config->{upstream} ) { |
43
|
|
|
|
|
|
|
for my $fld (qw(user repo)) { |
44
|
0
|
0
|
|
|
|
|
error_message( "You set upstream, but did not set '" . $fld . "'!" ) |
45
|
0
|
|
|
|
|
|
unless $config->{upstream}->{$fld}; |
46
|
|
|
|
|
|
|
$args{$fld} = $config->{upstream}->{$fld}; |
47
|
0
|
0
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return Pithub->new(%args); |
51
|
|
|
|
|
|
|
} |
52
|
0
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
before [ 'cmd_start', 'cmd_continue', 'cmd_append' ] => sub { |
54
|
|
|
|
|
|
|
my $self = shift; |
55
|
|
|
|
|
|
|
return unless $self->has_issue; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $issuename = 'issue#' . $self->issue; |
58
|
|
|
|
|
|
|
$self->insert_tag($issuename); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $cfg = $self->config->{github}; |
61
|
|
|
|
|
|
|
my $response = |
62
|
|
|
|
|
|
|
$self->github_client->issues->get( repo => $cfg->{repo}, issue_id => $self->issue ); |
63
|
|
|
|
|
|
|
unless ( $response->success ) { |
64
|
|
|
|
|
|
|
error_message( "Cannot find issue %s in %s/%s", $self->issue, $cfg->@{ 'user', 'repo' } ); |
65
|
|
|
|
|
|
|
return; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
my $issue = $response->content; |
68
|
|
|
|
|
|
|
my $name = $issue->{title}; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
if ( defined $self->description ) { |
71
|
|
|
|
|
|
|
$self->description( $self->description . ' ' . $name ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
else { |
74
|
|
|
|
|
|
|
$self->description($name); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
if ( $self->meta->does_role('App::TimeTracker::Command::Git') ) { |
78
|
|
|
|
|
|
|
my $branch = $self->issue; |
79
|
|
|
|
|
|
|
if ($name) { |
80
|
|
|
|
|
|
|
$branch = $self->safe_branch_name( $self->issue . ' ' . $name ); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
$branch =~ s/_/-/g; |
83
|
|
|
|
|
|
|
$self->branch( lc($branch) ) unless $self->branch; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
}; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $self = shift; |
88
|
|
|
|
|
|
|
foreach my $tag ( @{ $self->tags } ) { |
89
|
|
|
|
|
|
|
next unless $tag =~ /^issue#(\d+)/; |
90
|
0
|
|
|
0
|
0
|
|
return $1; |
91
|
0
|
|
|
|
|
|
} |
|
0
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
} |
93
|
0
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
no Moose::Role; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
q{ listening to: Train noises on my way from Wien to Graz } |
97
|
1
|
|
|
1
|
|
10
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=pod |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=encoding UTF-8 |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 NAME |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
App::TimeTracker::Command::GitHub - App::TimeTracker GitHub plugin |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 VERSION |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
version 1.002 |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 DESCRIPTION |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Connect tracker with L<GitHub|https://github.com/>. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Using the GitHub plugin, tracker can fetch the name of an issue and use |
116
|
|
|
|
|
|
|
it as the task's description; generate a nicely named C<git> branch |
117
|
|
|
|
|
|
|
(if you're also using the C<Git> plugin). |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 CONFIGURATION |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 plugins |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Add C<GitHub> to the list of plugins. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 github |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
add a hash named C<github>, containing the following keys: |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head3 user [REQUIRED] |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Your github user name. Best stored in your global TimeTracker config file. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head3 token [REQUIRED] |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Your personal access token. Get it from your github settings |
136
|
|
|
|
|
|
|
(Developer Settings, Personal access token): https://github.com/settings/tokens |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Best stored in your global TimeTracker config file. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head3 repo [REQUIRED] |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
The name of the repository you are working on. Currently a required |
143
|
|
|
|
|
|
|
entry to the config file, but we might upgrade it to a command line |
144
|
|
|
|
|
|
|
param and/or try to guess it from the current working dir or your git |
145
|
|
|
|
|
|
|
config. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head3 api_uri |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Optional. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Set this to the URL of your local GitHub Enterprise installation. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head3 upstream |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Optional. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
If the project you are working on has an upstream project where issues are |
158
|
|
|
|
|
|
|
handled, then you can set upstream to a hash of user and repo (like on a normal |
159
|
|
|
|
|
|
|
project) to fetch issues from there. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 NEW COMMANDS |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
No new commands |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 CHANGES TO OTHER COMMANDS |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 start, continue |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head3 --issue |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
~/perl/Your-Project$ tracker start --issue 42 |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
If C<--issue> is set and we can find an issue with this id in your current repo |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=over |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item * set or append the issue name in the task description ("Rev up FluxCompensator!!") |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item * add the issue id to the tasks tags ("issue#42") |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item * if C<Git> is also used, determine a save branch name from the issue name, and change into this branch ("42-rev-up-fluxcompensator") |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item * TODO: assign to your user, if C<set_assignee> is set and issue is not assigned |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item * TODO: reopen a closed issue if C<reopen> is set |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=item * TODO: modifiy the labels by adding all labels listed in C<labels_on_start.add> and removing all lables listed in C<labels_on_start.add> |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=back |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 Contributors |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=over |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item * L<Thomas MANTL|https://github.com/TM2500> |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=back |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 AUTHOR |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Thomas Klausner <domm@plix.at> |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This software is copyright (c) 2020 by Thomas Klausner. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
208
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=cut |