line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::GHPT::WorkSubmitter::ChangedFiles; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
8
|
use App::GHPT::Wrapper::OurMoose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
12
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.000012'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
12
|
use List::Util 1.44 qw( any uniq ); |
|
1
|
|
|
|
|
36
|
|
|
1
|
|
|
|
|
183
|
|
8
|
1
|
|
|
1
|
|
9
|
use App::GHPT::Types qw( ArrayRef HashRef Str ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has [ |
11
|
|
|
|
|
|
|
qw( |
12
|
|
|
|
|
|
|
added_files |
13
|
|
|
|
|
|
|
all_files |
14
|
|
|
|
|
|
|
deleted_files |
15
|
|
|
|
|
|
|
modified_files |
16
|
|
|
|
|
|
|
) |
17
|
|
|
|
|
|
|
] => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => ArrayRef [Str], |
20
|
|
|
|
|
|
|
required => 1, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has _file_exists_hash => ( |
24
|
|
|
|
|
|
|
is => 'ro', |
25
|
|
|
|
|
|
|
isa => HashRef, |
26
|
|
|
|
|
|
|
lazy => 1, |
27
|
|
|
|
|
|
|
builder => '_build_file_exists_hash', |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
|
|
sub _build_file_exists_hash ($self) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
return +{ map { $_ => 1 } $self->all_files->@* }; |
|
0
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
0
|
1
|
|
sub changed_files ($self) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
return [ uniq sort $self->added_files->@*, $self->modified_files->@* ]; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
1
|
|
sub changed_files_match ( $self, $regex ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
|
|
return any { $_ =~ $regex } $self->changed_files->@*; |
|
0
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
0
|
1
|
|
sub changed_files_matching ( $self, $regex ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return grep { $_ =~ $regex } $self->changed_files->@*; |
|
0
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
0
|
1
|
|
sub file_exists ( $self, $path ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return $self->_file_exists_hash->{$path}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# this is inefficently written, but it shouldn't really make any difference |
51
|
|
|
|
|
|
|
# for the number of files we're talking about here |
52
|
0
|
|
|
0
|
1
|
|
sub file_status ( $self, $path ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
53
|
0
|
0
|
|
0
|
|
|
return 'A' if any { $_ eq $path } $self->added_files->@*; |
|
0
|
|
|
|
|
|
|
54
|
0
|
0
|
|
0
|
|
|
return 'M' if any { $_ eq $path } $self->modified_files->@*; |
|
0
|
|
|
|
|
|
|
55
|
0
|
0
|
|
0
|
|
|
return 'D' if any { $_ eq $path } $self->deleted_files->@*; |
|
0
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
|
return q{ } if $self->file_exists($path); |
57
|
0
|
|
|
|
|
|
return undef; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# ABSTRACT: Contains all the files that were modified or added in a branch |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=pod |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=encoding UTF-8 |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 NAME |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
App::GHPT::WorkSubmitter::ChangedFiles - Contains all the files that were modified or added in a branch |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 VERSION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
version 1.000012 |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 SYNOPSIS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 DESCRIPTION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
A class that represents what files were added, modified or deleted in a |
85
|
|
|
|
|
|
|
branch, as well as what files exist in the branch. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Normally constructed by L<App::GHPT::WorkSubmitter::ChangedFilesFactory>. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=for test_synopsis use v5.20; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
my $factory = App::GHPT::WorkSubmitter::ChangedFilesFactory->new( |
92
|
|
|
|
|
|
|
merge_to_branch_name => 'master', |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $changed_files = $factory->changed_files; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# print out all modified / added file in this branch |
98
|
|
|
|
|
|
|
say for $changed_files->changed_files->@*; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 added_files |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
All files added in this branch. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Arrayref of String. Required. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 modified_files |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
All files modified in this branch (excluding those that were added in this |
111
|
|
|
|
|
|
|
branch) |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Arrayref of String. Required. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 deleted_files |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
All files deleted in this branch. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Arrayref of String. Required. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 all_files |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
All files in this branch (including those created before the branch was |
124
|
|
|
|
|
|
|
branched.) i.e. every file that you'd get from a fresh checkout of this |
125
|
|
|
|
|
|
|
branch. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Arrayref of String. Required. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 METHODS |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 $changed->changed_files |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
All changed files (i.e. all files that were either added or modified in |
134
|
|
|
|
|
|
|
this branch.) Returns Arrayref of Strings. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 $changed->changed_files_match( $regex ) |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Returns true iff any of the changed files filenames match the passed regex |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 $changed->changed_files_matching( $regex ) |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Returns a list of changed files filenames matching the passed regex |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 $changed->file_exists( $path ) |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Does the passed file exist on the branch (i.e. if you were to do a fresh |
147
|
|
|
|
|
|
|
checkout of this branch would the file be present) |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 $changed->file_status( $path ) |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Returns the file status. This is either C<A> (added), C<D> (deleted), C<M> |
152
|
|
|
|
|
|
|
(modified), C< > (exists, not modified) or undef (doesn't exist). |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 SUPPORT |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Bugs may be submitted through L<https://github.com/maxmind/App-GHPT/issues>. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 AUTHORS |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=over 4 |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item * |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Mark Fowler <mark@twoshortplanks.com> |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item * |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=back |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This software is Copyright (c) 2019 by MaxMind, Inc. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
This is free software, licensed under: |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |