Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format copyright year as "X - Y" when the year in the config is not t… #578

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Revision history for {{$dist->name}}

{{$NEXT}}
- if the copyright_year in the dist.ini is not this year, the
copyright statement and license are formatted as "$year -
$current_year" (Dave Rolsky, github #578)

6.008 2016-10-05 21:35:23-04:00 America/New_York
- fix the skip message from ExtraTests (thanks, Roy Ivy Ⅲ!)
Expand Down
8 changes: 7 additions & 1 deletion lib/Dist/Zilla.pm
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,15 @@ sub _build_license {
);
}

my $this_year = (localtime)[5] + 1900;
my $years
= $copyright_year == $this_year
? $copyright_year
: "$copyright_year - $this_year";

my $license = $license_class->new({
holder => $self->_copyright_holder,
year => $self->_copyright_year,
year => $years,
});

$self->_clear_license_class;
Expand Down
4 changes: 2 additions & 2 deletions t/plugins/license.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ subtest "ASCII-only author" => sub {
{ dist_root => 'corpus/dist/DZT' },
{
add_files => {
'source/dist.ini' => simple_ini('License'),
'source/dist.ini' => simple_ini({ copyright_year => 2012 }, 'License'),
},
},
);
Expand All @@ -22,7 +22,7 @@ subtest "ASCII-only author" => sub {

like(
$contents,
qr{This software is copyright .c. [0-9]+ by E\. Xavier Ample}i,
qr{This software is copyright .c. 2012 - \d\d\d\d by E\. Xavier Ample}i,
"copyright appears in LICENSE file",
);

Expand Down