This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix deparsing of require "a".$1
[perl5.git] / Porting / acknowledgements.pl
CommitLineData
548e9a3a
LB
1#!perl
2
3=head1 NAME
4
5Porting/acknowledgements.pl - Generate perldelta acknowledgements text
6
7=head1 SYNOPSIS
8
9 perl Porting/acknowledgements.pl v5.15.0..HEAD
10
11=head1 DESCRIPTION
12
13This generates the text which goes in the Acknowledgements section in
14a perldelta. You pass in the previous version and it guesses the next
15version, fetches information from the repository and outputs the
16text.
17
18=cut
19
20use strict;
21use warnings;
22use autodie;
23use POSIX qw(ceil);
24use Text::Wrap;
25use Time::Piece;
26use Time::Seconds;
27use version;
28$Text::Wrap::columns = 80;
29
30my $since_until = shift;
31
32my ( $since, $until ) = split '\.\.', $since_until;
33
34die "Usage: perl Porting/acknowledgements.pl v5.15.0..HEAD"
35 unless $since_until && $since && $until;
36
37my $previous_version = previous_version();
38my $next_version = next_version();
39my $development_time = development_time();
40
41my ( $changes, $files ) = changes_files();
42my $formatted_changes = commify( round($changes) );
43my $formatted_files = commify( round($files) );
44
45my $authors = authors();
46my $nauthors = $authors =~ tr/,/,/;
47$nauthors++;
48
49my $text
50 = "Perl $next_version represents approximately $development_time of development
51since Perl $previous_version and contains approximately $formatted_changes
52lines of changes across $formatted_files files from $nauthors authors.
53
9fe5af70
FR
54Perl continues to flourish into its third decade thanks to a vibrant
55community of users and developers. The following people are known to
548e9a3a
LB
56have contributed the improvements that became Perl $next_version:
57
58$authors
59The list above is almost certainly incomplete as it is automatically
60generated from version control history. In particular, it does not
61include the names of the (very much appreciated) contributors who
62reported issues to the Perl bug tracker.
63
64Many of the changes included in this version originated in the CPAN
65modules included in Perl's core. We're grateful to the entire CPAN
66community for helping Perl to flourish.
67
68For a more complete list of all of Perl's historical contributors,
9fe5af70 69please see the F<AUTHORS> file in the Perl source distribution.";
548e9a3a
LB
70
71my $wrapped = fill( '', '', $text );
72print "$wrapped\n";
73
74# return the previous Perl version, eg 5.15.0
75sub previous_version {
76 my $version = version->new($since);
77 $version =~ s/^v//;
78 return $version;
79}
80
81# returns the upcoming release Perl version, eg 5.15.1
82sub next_version {
83 my $version = version->new($since);
84 ( $version->{version}->[-1] )++;
85 return version->new( join( '.', @{ $version->{version} } ) );
86}
87
88# returns the development time since the previous version in weeks
89# or months
90sub development_time {
91 my $dates = qx(git log --pretty=format:%ct --summary $since_until);
92 my $first_timestamp;
93 foreach my $line ( split $/, $dates ) {
94 next unless $line;
95 next unless $line =~ /^\d+$/;
96 $first_timestamp = $line;
97 }
98
99 die "Missing first timestamp" unless $first_timestamp;
100
101 my $now = localtime;
102 my $then = localtime($first_timestamp);
103 my $seconds = $now - $then;
104 my $weeks = ceil( $seconds / ONE_WEEK );
105 my $months = ceil( $seconds / ONE_MONTH );
106
107 my $development_time;
108 if ( $months < 2 ) {
109 return "$weeks weeks";
110 } else {
111 return "$months months";
112 }
113}
114
115# returns the number of changed lines and files since the previous
116# version
117sub changes_files {
118 my $output = qx(git diff --shortstat $since_until);
119
120 # 585 files changed, 156329 insertions(+), 53586 deletions(-)
121 my ( $files, $insertions, $deletions )
122 = $output
123 =~ /(\d+) files changed, (\d+) insertions\(\+\), (\d+) deletions\(-\)/;
124 my $changes = $insertions + $deletions;
125 return ( $changes, $files );
126}
127
128# rounds an integer to two significant figures
129sub round {
130 my $int = shift;
131 my $length = length($int);
132 my $divisor = 10**( $length - 2 );
133 return ceil( $int / $divisor ) * $divisor;
134}
135
136# adds commas to a number at thousands, millions
137sub commify {
138 local $_ = shift;
139 1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
140 return $_;
141}
142
143# returns a list of the authors
144sub authors {
145 return
146 qx(git log --pretty=fuller $since_until | $^X Porting/checkAUTHORS.pl --who -);
147}