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: dev |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
961
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
42
|
|
10
|
1
|
|
|
1
|
|
4
|
use version; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
11
|
1
|
|
|
1
|
|
213
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use Carp; |
13
|
|
|
|
|
|
|
use Data::Dumper qw/Dumper/; |
14
|
|
|
|
|
|
|
use English qw/ -no_match_vars /; |
15
|
|
|
|
|
|
|
use File::chdir; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = version->new('0.0.2'); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $opt = Getopt::Alt->new( |
20
|
|
|
|
|
|
|
{ |
21
|
|
|
|
|
|
|
helper => 1, |
22
|
|
|
|
|
|
|
help => __PACKAGE__, |
23
|
|
|
|
|
|
|
default => { |
24
|
|
|
|
|
|
|
min => 1, |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
[ |
28
|
|
|
|
|
|
|
'min|min-commits|m=i', |
29
|
|
|
|
|
|
|
'name|n', |
30
|
|
|
|
|
|
|
'no_release|no-release', |
31
|
|
|
|
|
|
|
'verbose|v+', |
32
|
|
|
|
|
|
|
'quiet|q!', |
33
|
|
|
|
|
|
|
] |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub since_release { |
37
|
|
|
|
|
|
|
my ($self, $name) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return unless -d $name; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$opt->process if !%{ $opt->opt || {} }; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
local $CWD = $name; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# find the newest tag and count newer commits |
46
|
|
|
|
|
|
|
my @tags = map {/(.*)$/; $1} `git tag`; |
47
|
|
|
|
|
|
|
if ($opt->opt->no_release) { |
48
|
|
|
|
|
|
|
return "Never released" if !@tags; |
49
|
|
|
|
|
|
|
return; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
elsif (!@tags) { |
52
|
|
|
|
|
|
|
return; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my ($sha, $time) = split /\s+/, `git log -n 1 --format=format:'%H %at' $tags[-1]`; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my @logs = `git log -n 100 --format=format:'%H'`; |
58
|
|
|
|
|
|
|
my $count = -1; |
59
|
|
|
|
|
|
|
for my $log (@logs) { |
60
|
|
|
|
|
|
|
$count++; |
61
|
|
|
|
|
|
|
chomp $log; |
62
|
|
|
|
|
|
|
last if $log eq $sha; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
return if $count < $opt->opt->min && !$opt->opt->verbose; |
66
|
|
|
|
|
|
|
my $text = $opt->opt->quiet ? '' : "Commits since last release"; |
67
|
|
|
|
|
|
|
$text .= $opt->opt->name ? " ($tags[-1]): " : ': '; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
return "$text$count\n"; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 NAME |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Group::Git::Cmd::SinceRelease - Gets the number of commits each repository is ahead of the last release |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 VERSION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This documentation refers to Group::Git::Cmd::SinceRelease version 0.0.2 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SYNOPSIS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
group-git since-release [options] |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Options: |
89
|
|
|
|
|
|
|
-m --min-commits[=]int |
90
|
|
|
|
|
|
|
Set the minimum number of commits to be found since the |
91
|
|
|
|
|
|
|
last release (ie tag) before the results are shown. |
92
|
|
|
|
|
|
|
(Default 1) |
93
|
|
|
|
|
|
|
-n --name Show the last release's name (ignored if --quiet used) |
94
|
|
|
|
|
|
|
--no-release |
95
|
|
|
|
|
|
|
Show only repositories that have never been released (no tags) |
96
|
|
|
|
|
|
|
-q --quiet Just show the number of commits since the last release |
97
|
|
|
|
|
|
|
-v --verbose Show all repository results. |
98
|
|
|
|
|
|
|
--help Show this documentation |
99
|
|
|
|
|
|
|
--man Show full documentation |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 DESCRIPTION |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 C<since_release <$name> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Calculates the number of commits since the last release (aka newest tag) |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 DESCRIPTION |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 C<tag ($name)> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Does the work of finding tags |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
There are no known bugs in this module. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Please report problems to Ivan Wills (ivan.wills@gmail.com). |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Patches are welcome. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 AUTHOR |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Ivan Wills - (ivan.wills@gmail.com) |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Copyright (c) 2013 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). |
140
|
|
|
|
|
|
|
All rights reserved. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
143
|
|
|
|
|
|
|
the same terms as Perl itself. See L<perlartistic>. This program is |
144
|
|
|
|
|
|
|
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
145
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
146
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=cut |