5 Porting/acknowledgements.pl - Generate perldelta acknowledgements text
9 perl Porting/acknowledgements.pl v5.15.0..HEAD
13 This generates the text which goes in the Acknowledgements section in
14 a perldelta. You pass in the previous version and it guesses the next
15 version, fetches information from the repository and outputs the
28 $Text::Wrap::columns = 80;
30 my $since_until = shift;
32 my ( $since, $until ) = split '\.\.', $since_until;
34 die "Usage: perl Porting/acknowledgements.pl v5.15.0..HEAD"
35 unless $since_until && $since && $until;
37 my $previous_version = previous_version();
38 my $next_version = next_version();
39 my $development_time = development_time();
41 my ( $changes, $files ) = changes_files();
42 my $formatted_changes = commify( round($changes) );
43 my $formatted_files = commify( round($files) );
45 my $authors = authors();
46 my $nauthors = $authors =~ tr/,/,/;
50 = "Perl $next_version represents approximately $development_time of development
51 since Perl $previous_version and contains approximately $formatted_changes
52 lines of changes across $formatted_files files from $nauthors authors.
54 Perl continues to flourish into its third decade thanks to a vibrant
55 community of users and developers. The following people are known to
56 have contributed the improvements that became Perl $next_version:
59 The list above is almost certainly incomplete as it is automatically
60 generated from version control history. In particular, it does not
61 include the names of the (very much appreciated) contributors who
62 reported issues to the Perl bug tracker.
64 Many of the changes included in this version originated in the CPAN
65 modules included in Perl's core. We're grateful to the entire CPAN
66 community for helping Perl to flourish.
68 For a more complete list of all of Perl's historical contributors,
69 please see the F<AUTHORS> file in the Perl source distribution.";
71 my $wrapped = fill( '', '', $text );
74 # return the previous Perl version, eg 5.15.0
75 sub previous_version {
76 my $version = version->new($since);
81 # returns the upcoming release Perl version, eg 5.15.1
83 my $version = version->new($since);
84 ( $version->{version}->[-1] )++;
85 return version->new( join( '.', @{ $version->{version} } ) );
88 # returns the development time since the previous version in weeks
90 sub development_time {
91 my $first_timestamp = qx(git log -1 --pretty=format:%ct --summary $since);
92 my $last_timestamp = qx(git log -1 --pretty=format:%ct --summary $until);
94 die "Missing first timestamp" unless $first_timestamp;
95 die "Missing last timestamp" unless $last_timestamp;
97 my $seconds = localtime($last_timestamp) - localtime($first_timestamp);
98 my $weeks = _round( $seconds / ONE_WEEK );
99 my $months = _round( $seconds / ONE_MONTH );
101 my $development_time;
103 return "$weeks @{[$weeks == 1 ? q(week) : q(weeks)]}";
105 return "$months months";
113 my $remainder = $val - $int;
115 return $remainder >= 0.5 ? $int + 1 : $int;
118 # returns the number of changed lines and files since the previous
121 my $output = qx(git diff --shortstat $since_until);
123 # 585 files changed, 156329 insertions(+), 53586 deletions(-)
124 my ( $files, $insertions, $deletions )
126 =~ /(\d+) files changed, (\d+) insertions\(\+\), (\d+) deletions\(-\)/;
127 my $changes = $insertions + $deletions;
128 return ( $changes, $files );
131 # rounds an integer to two significant figures
134 my $length = length($int);
135 my $divisor = 10**( $length - 2 );
136 return ceil( $int / $divisor ) * $divisor;
139 # adds commas to a number at thousands, millions
142 1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
146 # returns a list of the authors
149 qx(git log --pretty=fuller $since_until | $^X Porting/checkAUTHORS.pl --who -);