line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OTRS::OPM::Maker::Command::changes; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
117893
|
use strict; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
26
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Generate changes file based on vcs commits |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
52
|
|
9
|
1
|
|
|
1
|
|
287
|
use File::Find::Rule; |
|
1
|
|
|
|
|
6956
|
|
|
1
|
|
|
|
|
7
|
|
10
|
1
|
|
|
1
|
|
51
|
use File::Basename; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
11
|
1
|
|
|
1
|
|
6
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
12
|
1
|
|
|
1
|
|
325
|
use IO::File; |
|
1
|
|
|
|
|
7080
|
|
|
1
|
|
|
|
|
102
|
|
13
|
1
|
|
|
1
|
|
498
|
use JSON; |
|
1
|
|
|
|
|
8057
|
|
|
1
|
|
|
|
|
6
|
|
14
|
1
|
|
|
1
|
|
183
|
use List::Util qw(first); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
97
|
|
15
|
1
|
|
|
1
|
|
247
|
use Path::Class (); |
|
1
|
|
|
|
|
29801
|
|
|
1
|
|
|
|
|
40
|
|
16
|
1
|
|
|
1
|
|
447
|
use Time::Piece; |
|
1
|
|
|
|
|
9484
|
|
|
1
|
|
|
|
|
7
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
124
|
use OTRS::OPM::Maker -command; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
13
|
|
19
|
1
|
|
|
1
|
|
5605
|
use OTRS::OPM::Maker::Utils::Git; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
669
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = 0.02; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub abstract { |
24
|
0
|
|
|
0
|
1
|
0
|
return "Generate changes file based on git commits"; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub usage_desc { |
28
|
0
|
|
|
0
|
1
|
0
|
return "opmbuild changes [--file ] [--dir ]"; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub opt_spec { |
32
|
|
|
|
|
|
|
return ( |
33
|
0
|
|
|
0
|
1
|
0
|
[ 'file=s', 'Path to .changes file' ], |
34
|
|
|
|
|
|
|
[ 'dir=s', 'Directory of the addon' ], |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub validate_args { |
39
|
1
|
|
|
1
|
1
|
199
|
my ($self, $opt, $args) = @_; |
40
|
|
|
|
|
|
|
|
41
|
1
|
50
|
|
|
|
5
|
if ( !$opt->{dir} ) { |
42
|
0
|
|
|
|
|
0
|
$opt->{dir} = OTRS::OPM::Maker::Utils::Git->find_toplevel( dir => '.' ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
1
|
50
|
|
|
|
6
|
if ( !$opt->{dir} ) { |
46
|
0
|
|
|
|
|
0
|
$self->usage_error( 'no directory with addon found' ); |
47
|
0
|
|
|
|
|
0
|
exit; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
1
|
50
|
|
|
|
4
|
if ( !$opt->{file} ) { |
51
|
1
|
|
|
|
|
3
|
my @parts = $opt->{dir}; |
52
|
1
|
50
|
|
|
|
35
|
if ( -d $opt->{dir} . '/doc' ) { |
53
|
0
|
|
|
|
|
0
|
push @parts, 'doc'; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
59
|
my $name = (File::Spec->splitpath( File::Spec->rel2abs( $opt->{dir} ) ) ) [-1]; |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
13
|
$opt->{file} = File::Spec->catfile( |
59
|
|
|
|
|
|
|
@parts, |
60
|
|
|
|
|
|
|
$name . '.changes', |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub execute { |
66
|
1
|
|
|
1
|
1
|
7
|
my ($self, $opt, $args) = @_; |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
16
|
chdir $opt->{dir}; |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
13
|
my $changes_file = Path::Class::File->new( $opt->{file} ); |
71
|
1
|
|
|
|
|
193
|
my @entries; |
72
|
|
|
|
|
|
|
my $lines; |
73
|
|
|
|
|
|
|
|
74
|
1
|
50
|
|
|
|
4
|
if ( -f $changes_file->stringify ) { |
75
|
0
|
|
|
|
|
0
|
$lines = $changes_file->slurp( iomode => '<:encoding(UTF-8)' ); |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
0
|
|
|
0
|
my @entries = grep{ ( $_ // '' ) ne '' }split m{ |
|
0
|
|
|
|
|
0
|
|
78
|
|
|
|
|
|
|
(?:\s+)? |
79
|
|
|
|
|
|
|
( # headline with version and date |
80
|
|
|
|
|
|
|
^ |
81
|
|
|
|
|
|
|
\d+\.\d+ (?:\.\d+)? # version |
82
|
|
|
|
|
|
|
\s+ -? \s+ |
83
|
|
|
|
|
|
|
\d{4}-\d{2}-\d{2} (?:\s|T) # date |
84
|
|
|
|
|
|
|
\d{2}:\d{2}:\d{2} (?:[+-]\d+:\d+)?\s # time |
85
|
|
|
|
|
|
|
(?: - \s [a-f0-9]+ )? # optional git commit |
86
|
|
|
|
|
|
|
) |
87
|
|
|
|
|
|
|
\s+ |
88
|
|
|
|
|
|
|
}xms, $lines; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
1
|
|
|
|
|
71
|
my $last_version; |
92
|
|
|
|
|
|
|
my $last_commit; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
ENTRY: |
95
|
1
|
|
|
|
|
6
|
while ( @entries ) { |
96
|
0
|
|
|
|
|
0
|
my ($header, $desc) = ( shift(@entries), shift(@entries) ); |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
0
|
|
|
0
|
my ($version, $date, $commit) = split /\s+-\s+/, $header // ''; |
99
|
|
|
|
|
|
|
|
100
|
0
|
0
|
|
|
|
0
|
if ( $version ) { |
101
|
0
|
|
|
|
|
0
|
$last_version = $version; |
102
|
0
|
|
|
|
|
0
|
$last_commit = $commit; |
103
|
0
|
|
|
|
|
0
|
last ENTRY; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
1
|
|
50
|
|
|
12
|
$last_version //= ''; |
108
|
1
|
|
50
|
|
|
8
|
$lines //= ''; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
my $new = OTRS::OPM::Maker::Utils::Git->commits( |
111
|
|
|
|
|
|
|
version => $last_version, |
112
|
|
|
|
|
|
|
dir => $opt->{dir}, |
113
|
1
|
|
|
|
|
12
|
); |
114
|
|
|
|
|
|
|
|
115
|
1
|
50
|
|
|
|
15
|
my @all_lines = ( $new, $lines ? $lines : () ); |
116
|
|
|
|
|
|
|
|
117
|
1
|
50
|
|
|
|
18
|
my $fh = IO::File->new( $changes_file->stringify, 'w' ) or die $!; |
118
|
1
|
|
|
|
|
458
|
$fh->print( join "\n\n", @all_lines ); |
119
|
1
|
|
|
|
|
35
|
$fh->close; |
120
|
|
|
|
|
|
|
|
121
|
1
|
|
|
|
|
58
|
return $changes_file->stringify; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
__END__ |