diff options
author | Dave Rolsky <autarch@urth.org> | 2011-12-23 11:01:34 -0600 |
---|---|---|
committer | Dave Rolsky <autarch@urth.org> | 2011-12-23 11:01:34 -0600 |
commit | 5f8b560c2ebd66afd8ccc9364f425281a1b966a2 (patch) | |
tree | bd7decaeff4ee96c814dd677619bd75ca3002aaa | |
parent | 238d254681445c9b60a2a1334d374e5b187e4733 (diff) | |
download | perl-5f8b560c2ebd66afd8ccc9364f425281a1b966a2.tar.gz |
Fix the calculation for development time so it doesn't come up with things like "2 months" between two dev releases
There were a couple bugs ...
First, we should just use the date of the two commits we're looking at rather
than looking at all the commits in between and picking the earliest one. This
can find _much_ earlier things that weren't merged until much later, which
really throws the numbers off.
Second, when calculating the number of weeks and months, we shouldn't use
POSIX::ceil(), that rounds up 4.01 weeks to 5. Instead, I wrote a simple
rounding function that does standard rounding.
-rw-r--r-- | Porting/acknowledgements.pl | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/Porting/acknowledgements.pl b/Porting/acknowledgements.pl index 5f36b8ffbf..bdfef41f2b 100644 --- a/Porting/acknowledgements.pl +++ b/Porting/acknowledgements.pl @@ -88,21 +88,15 @@ sub next_version { # returns the development time since the previous version in weeks # or months sub development_time { - my $dates = qx(git log --pretty=format:%ct --summary $since_until); - my $first_timestamp; - foreach my $line ( split $/, $dates ) { - next unless $line; - next unless $line =~ /^\d+$/; - $first_timestamp = $line; - } + my $first_timestamp = qx(git log -1 --pretty=format:%ct --summary $since); + my $last_timestamp = qx(git log -1 --pretty=format:%ct --summary $until); die "Missing first timestamp" unless $first_timestamp; + die "Missing last timestamp" unless $last_timestamp; - my $now = localtime; - my $then = localtime($first_timestamp); - my $seconds = $now - $then; - my $weeks = ceil( $seconds / ONE_WEEK ); - my $months = ceil( $seconds / ONE_MONTH ); + my $seconds = localtime($last_timestamp) - localtime($first_timestamp); + my $weeks = _round( $seconds / ONE_WEEK ); + my $months = _round( $seconds / ONE_MONTH ); my $development_time; if ( $months < 2 ) { @@ -112,6 +106,15 @@ sub development_time { } } +sub _round { + my $val = shift; + + my $int = int $val; + my $remainder = $val - $int; + + return $remainder >= 0.5 ? $int + 1 : $int; +} + # returns the number of changed lines and files since the previous # version sub changes_files { |