3 #=======================================================================
5 # File ID: dc91cf88-abf1-11e5-bfdc-fefdb24f8e10
7 # Estimate when a project in Git will reach a certain number of commits.
10 # ©opyleft 2015– Øyvind A. Holm <sunny@sunbase.org>
11 # License: GNU General Public License version 2 or later, see end of
12 # file for legal stuff.
13 #=======================================================================
33 $progname =~ s/^.*\/(.*?)$/$1/;
34 our $VERSION = '0.2.0';
36 Getopt
::Long
::Configure
('bundling');
39 'goal|g=i' => \
$Opt{'goal'},
40 'help|h' => \
$Opt{'help'},
41 'quiet|q+' => \
$Opt{'quiet'},
42 'ref|r=s' => \
$Opt{'ref'},
43 'verbose|v+' => \
$Opt{'verbose'},
44 'version' => \
$Opt{'version'},
46 ) || die("$progname: Option error. Use -h for help.\n");
48 $Opt{'verbose'} -= $Opt{'quiet'};
49 $Opt{'help'} && usage
(0);
50 if ($Opt{'version'}) {
61 if (!length($Opt{'goal'})) {
62 warn("$progname: -g/--goal not specified\n");
66 if (!length($Opt{'ref'})) {
67 warn("$progname: -r/--ref not specified\n");
71 chomp(my $begindate = `git log -1 $Opt{'ref'} --format=%ct`);
72 msg
(2, "begindate = \"$begindate\"");
73 chomp(my $beginvalue = `git log --format=%h $Opt{'ref'} | wc -l`);
74 msg
(2, "beginvalue = \"$beginvalue\"");
75 chomp(my $currentvalue = `git log --format=%h | wc -l`);
79 sec_to_string
($begindate, " "),
90 # Print program version {{{
91 print("$progname $VERSION\n");
97 # Convert seconds since 1970 to "yyyymmddThhmmss[.frac]Z" {{{
98 my ($Seconds, $Sep) = @_;
99 length($Seconds) || return('');
100 ($Seconds =~ /^-?(\d*)(\.\d+)?$/) || return(undef);
101 my $Secfrac = ($Seconds =~ /^([\-\d]*)(\.\d+)$/) ?
1.0*$2 : "";
104 defined($Sep) || ($Sep = " ");
105 my @TA = gmtime($Seconds);
106 my($DateString) = sprintf("%04u-%02u-%02u %02u:%02u:%02u",
107 $TA[5]+1900, $TA[4]+1, $TA[3],
108 $TA[2], $TA[1], $TA[0]);
114 # Send the help message to stdout {{{
117 if ($Opt{'verbose'}) {
123 Estimate when a project in Git will reach a certain number of commits.
125 Usage: $progname [options] -r REF -g GOAL
130 Estimate when the repository will reach NUM commits.
134 Be more quiet. Can be repeated to increase silence.
136 Commit or tag to use as start value.
138 Increase level of verbosity. Can be repeated.
140 Print version information.
148 # Print a status message to stderr based on verbosity level {{{
149 my ($verbose_level, $Txt) = @_;
151 if ($Opt{'verbose'} >= $verbose_level) {
152 print(STDERR
"$progname: $Txt\n");
160 # This program is free software; you can redistribute it and/or modify
161 # it under the terms of the GNU General Public License as published by
162 # the Free Software Foundation; either version 2 of the License, or (at
163 # your option) any later version.
165 # This program is distributed in the hope that it will be useful, but
166 # WITHOUT ANY WARRANTY; without even the implied warranty of
167 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
168 # See the GNU General Public License for more details.
170 # You should have received a copy of the GNU General Public License
171 # along with this program.
172 # If not, see L<http://www.gnu.org/licenses/>.
174 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :