line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Group::Git::Cmd::SinceRelease; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2013-05-20 09:03:03 |
4
|
|
|
|
|
|
|
# Create by: Ivan Wills |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
22873
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
10
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
11
|
1
|
|
|
1
|
|
597
|
use version; |
|
1
|
|
|
|
|
2499
|
|
|
1
|
|
|
|
|
7
|
|
12
|
1
|
|
|
1
|
|
705
|
use Moose::Role; |
|
1
|
|
|
|
|
411782
|
|
|
1
|
|
|
|
|
3
|
|
13
|
1
|
|
|
1
|
|
4458
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
66
|
|
14
|
1
|
|
|
1
|
|
633
|
use Data::Dumper qw/Dumper/; |
|
1
|
|
|
|
|
5999
|
|
|
1
|
|
|
|
|
89
|
|
15
|
1
|
|
|
1
|
|
433
|
use English qw/ -no_match_vars /; |
|
1
|
|
|
|
|
2854
|
|
|
1
|
|
|
|
|
5
|
|
16
|
1
|
|
|
1
|
|
928
|
use File::chdir; |
|
1
|
|
|
|
|
2610
|
|
|
1
|
|
|
|
|
78
|
|
17
|
1
|
|
|
1
|
|
666
|
use Getopt::Alt; |
|
1
|
|
|
|
|
215426
|
|
|
1
|
|
|
|
|
5
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = version->new('0.0.10'); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $opt = Getopt::Alt->new( |
22
|
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
|
helper => 1, |
24
|
|
|
|
|
|
|
help => __PACKAGE__, |
25
|
|
|
|
|
|
|
default => { |
26
|
|
|
|
|
|
|
min => 1, |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
[ |
30
|
|
|
|
|
|
|
'min|min-commits|m=i', |
31
|
|
|
|
|
|
|
'name|n', |
32
|
|
|
|
|
|
|
'no_release|no-release', |
33
|
|
|
|
|
|
|
'released|r', |
34
|
|
|
|
|
|
|
'verbose|v+', |
35
|
|
|
|
|
|
|
'quiet|q!', |
36
|
|
|
|
|
|
|
] |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _num_sort { |
40
|
0
|
|
|
0
|
|
|
my $A = $a; |
41
|
0
|
0
|
|
|
|
|
$A =~ s/((0+)\d+)/sprintf "%03d", $2 eq '00' ? $1 : $2 eq '0' ? $1 * 10 : $1 * 100/egxms; |
|
0
|
0
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $B = $b; |
43
|
0
|
0
|
|
|
|
|
$B =~ s/((0+)\d+)/sprintf "%03d", $2 eq '00' ? $1 : $2 eq '0' ? $1 * 10 : $1 * 100/egxms; |
|
0
|
0
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$A cmp $B; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub since_release_start { |
48
|
0
|
|
|
0
|
1
|
|
$opt->process; |
49
|
0
|
|
|
|
|
|
return; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub since_release { |
53
|
0
|
|
|
0
|
1
|
|
my ($self, $name) = @_; |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
return unless -d $name; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
local $CWD = $name; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# find the newest tag and count newer commits |
60
|
0
|
|
|
|
|
|
my @tags = sort _num_sort map {/(.*)$/; $1} `git tag | sort -n`; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
if ($opt->opt->no_release) { |
|
|
0
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
return "Never released" if !@tags; |
63
|
0
|
|
|
|
|
|
return; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
elsif (!@tags) { |
66
|
0
|
|
|
|
|
|
return; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my ($sha, $time) = split /\s+/, `git log -n 1 --format=format:'%H %at' $tags[-1]`; |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
my $format = @ARGV ? join(' ', @ARGV) : '--format=format:" %s"'; |
72
|
0
|
|
|
|
|
|
my @logged = `git log -n 100 $format $sha..HEAD`; |
73
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
if ($opt->opt->released) { |
75
|
0
|
0
|
|
|
|
|
return "Released!" if !@logged; |
76
|
0
|
|
|
|
|
|
return; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
return if @logged < $opt->opt->min; |
80
|
0
|
0
|
|
|
|
|
my $text = $opt->opt->quiet ? '' : "Commits since last release ($tags[-1])"; |
81
|
0
|
0
|
|
|
|
|
$text .= $opt->opt->name ? " ($tags[-1]): " : ': '; |
82
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
return $text . ($opt->opt->verbose ? "\n" . join '', @logged : scalar @logged); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 NAME |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Group::Git::Cmd::SinceRelease - Gets the number of commits each repository is ahead of the last release |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 VERSION |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This documentation refers to Group::Git::Cmd::SinceRelease version 0.0.10 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SYNOPSIS |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
group-git since-release [(-m|--min-commits) n] [-n|--name] |
101
|
|
|
|
|
|
|
group-git since-release --no-release |
102
|
|
|
|
|
|
|
group-git since-release (-r|--released) |
103
|
|
|
|
|
|
|
group-git since-release [options] |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Options: |
106
|
|
|
|
|
|
|
-m --min-commits[=]int |
107
|
|
|
|
|
|
|
Set the minimum number of commits to be found since the |
108
|
|
|
|
|
|
|
last release (ie tag) before the results are shown. |
109
|
|
|
|
|
|
|
(Default 1) |
110
|
|
|
|
|
|
|
-n --name Show the last release's name (ignored if --quiet used) |
111
|
|
|
|
|
|
|
--no-release |
112
|
|
|
|
|
|
|
Show only repositories that have never been released (no tags) |
113
|
|
|
|
|
|
|
-r --released Show repositories that are currently released. |
114
|
|
|
|
|
|
|
-q --quiet Just show the number of commits since the last release |
115
|
|
|
|
|
|
|
-v --verbose Show all repository results. |
116
|
|
|
|
|
|
|
--help Show this documentation |
117
|
|
|
|
|
|
|
--man Show full documentation |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 DESCRIPTION |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
The C<since-release> command reports the statuses of repositories relative to |
122
|
|
|
|
|
|
|
their last release. Usually reporting the number of releases since the last |
123
|
|
|
|
|
|
|
release but with the C<--released> option shows only with no new commits since |
124
|
|
|
|
|
|
|
the last release. Also with the C<--no-release> option only repositories with |
125
|
|
|
|
|
|
|
no tagged releases are reported. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 C<since_release_start ()> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Initializes command line parameters. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 C<since_release ($name)> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Calculates the number of commits since the last release (via the newest tag) |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 DESCRIPTION |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 C<tag ($name)> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Does the work of finding tags |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
There are no known bugs in this module. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Please report problems to Ivan Wills (ivan.wills@gmail.com). |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Patches are welcome. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 AUTHOR |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Ivan Wills - (ivan.wills@gmail.com) |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Copyright (c) 2015 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). |
168
|
|
|
|
|
|
|
All rights reserved. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
171
|
|
|
|
|
|
|
the same terms as Perl itself. See L<perlartistic>. This program is |
172
|
|
|
|
|
|
|
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
173
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
174
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |