line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Group::Git::Cmd::Stats; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2013-07-07 20:48:23 |
4
|
|
|
|
|
|
|
# Create by: Ivan Wills |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
866
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
10
|
1
|
|
|
1
|
|
4
|
use version; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
11
|
1
|
|
|
1
|
|
190
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use Carp; |
13
|
|
|
|
|
|
|
use Data::Dumper qw/Dumper/; |
14
|
|
|
|
|
|
|
use English qw/ -no_match_vars /; |
15
|
|
|
|
|
|
|
use DateTime::Format::Strptime qw/strptime/; |
16
|
|
|
|
|
|
|
use File::chdir; |
17
|
|
|
|
|
|
|
use Getopt::Alt; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = version->new('0.0.2'); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $strp = DateTime::Format::Strptime->new( |
22
|
|
|
|
|
|
|
pattern => '%F %T %z', |
23
|
|
|
|
|
|
|
locale => 'en_AU', |
24
|
|
|
|
|
|
|
time_zone => 'Australia/Sydney', |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
my $opt = Getopt::Alt->new( |
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
helper => 1, |
29
|
|
|
|
|
|
|
help => __PACKAGE__, |
30
|
|
|
|
|
|
|
default => { |
31
|
|
|
|
|
|
|
bin => 'month' |
32
|
|
|
|
|
|
|
}, |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
[ |
35
|
|
|
|
|
|
|
'bin|b=s', |
36
|
|
|
|
|
|
|
] |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
my %global; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub stats { |
41
|
|
|
|
|
|
|
my ($self, $name) = @_; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
return unless -d $name; |
44
|
|
|
|
|
|
|
local $CWD = $name; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$opt->process if !%{ $opt->opt || {} }; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $cmd = qq{git log --format=format:' %h=|=%s=|=%an=|=%ci'}; |
49
|
|
|
|
|
|
|
my @commits = `$cmd`; |
50
|
|
|
|
|
|
|
my %stats; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
for my $commit (@commits) { |
53
|
|
|
|
|
|
|
my ($hash, $subject, $user, $time) = split /=[|]=/, $commit; |
54
|
|
|
|
|
|
|
$time = $strp->parse_datetime($time) || die "Can't parse the time $time!\nFrom:\n$commit\n"; |
55
|
|
|
|
|
|
|
my $stat = $time->clone; |
56
|
|
|
|
|
|
|
$stat->truncate( to => $opt->opt->bin ); |
57
|
|
|
|
|
|
|
push @{$stats{$stat}}, { |
58
|
|
|
|
|
|
|
hash => $hash, |
59
|
|
|
|
|
|
|
subject => $subject, |
60
|
|
|
|
|
|
|
user => $user, |
61
|
|
|
|
|
|
|
time => $time, |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
$global{ $stat } ||= {}; |
64
|
|
|
|
|
|
|
$global{ $stat }{count}++; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $out = ''; |
68
|
|
|
|
|
|
|
for my $stat ( sort keys %stats ) { |
69
|
|
|
|
|
|
|
$out .= sprintf "%s\t%d\n", $stat, scalar @{ $stats{$stat} }; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
return $out; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub stats_end { |
76
|
|
|
|
|
|
|
my ($self) = @_; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
return if !%{ $opt->opt || {} }; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $out = "\nTotal\n"; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
for my $stat ( sort keys %global ) { |
83
|
|
|
|
|
|
|
$out .= sprintf "%s\t%d\n", $stat, $global{$stat}{count}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
return $out; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 NAME |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Group::Git::Cmd::Stats - Show stats (from git log) about all projects |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 VERSION |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This documentation refers to Group::Git::Cmd::Stats version 0.0.2 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 SYNOPSIS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
group-git stats [options] |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Options: |
106
|
|
|
|
|
|
|
-b --bin[=](year|month|day|hour|minute|second) |
107
|
|
|
|
|
|
|
Put log counts into year/month/day ... groups |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
--help Show this help |
110
|
|
|
|
|
|
|
--man Show detailed help |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 DESCRIPTION |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=over 4 |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item stats |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Get repository stats |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item stats_end |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Output the collated stats |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=back |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
There are no known bugs in this module. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Please report problems to Ivan Wills (ivan.wills@gmail.com). |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Patches are welcome. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 AUTHOR |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Ivan Wills - (ivan.wills@gmail.com) |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Copyright (c) 2013 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). |
151
|
|
|
|
|
|
|
All rights reserved. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
154
|
|
|
|
|
|
|
the same terms as Perl itself. See L<perlartistic>. This program is |
155
|
|
|
|
|
|
|
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
156
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
157
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |