Skip to content

Commit

Permalink
Add single_version parameter to GitVersionCheckCJM
Browse files Browse the repository at this point in the history
  Bump version of dist & GitVersionCheckCJM to 4.27
  • Loading branch information
madsen committed Aug 29, 2015
1 parent b4ed931 commit 67d626f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Changes
Expand Up @@ -3,6 +3,10 @@ Revision history for Dist-Zilla-Plugins-CJM
Note: the version number of a plugin is the version of the dist in
which it was last changed.

4.27 NOT
[GitVersionCheckCJM]
- Add single_version parameter

4.26 2014-12-13
- Don't use Moose::Autobox (GitHub#3: Thanks, Olivier Mengué)
Dist::Zilla doesn't use it anymore, so it's an extra prerequisite.
Expand Down
2 changes: 1 addition & 1 deletion dist.ini
Expand Up @@ -6,7 +6,7 @@ author = Christopher J. Madsen <perl@cjmweb.net>
license = Perl_5
copyright_holder = Christopher J. Madsen

version = 4.26
version = 4.27

[FileFinder::Filter / :CheckRecommend]
finder = :InstallModules
Expand Down
22 changes: 21 additions & 1 deletion lib/Dist/Zilla/Plugin/GitVersionCheckCJM.pm
Expand Up @@ -17,7 +17,7 @@ package Dist::Zilla::Plugin::GitVersionCheckCJM;
# ABSTRACT: Ensure version numbers are up-to-date
#---------------------------------------------------------------------

our $VERSION = '4.26';
our $VERSION = '4.27';
# This file is part of {{$dist}} {{$dist_version}} ({{$date}})

=head1 SYNOPSIS
Expand Down Expand Up @@ -51,8 +51,21 @@ This FileFinder provides the list of modules that will be checked.
The default is C<:InstallModules>. The C<finder> attribute may be
listed any number of times.
=attr single_version
If set to a true value, all modules in the distribution must have
the distribution's version. The default is false, which allows
unchanged modules to retain the version of the distribution in which
they were last changed.
=cut

has single_version => (
is => 'ro',
isa => 'Bool',
default => 0,
);

# RECOMMEND PREREQ: Git::Wrapper
use Git::Wrapper (); # AutoPrereqs skips this

Expand Down Expand Up @@ -130,6 +143,13 @@ sub munge_file
return 1;
}

# If all modules must have the same version,
# and the module version is less than the dist version, that's a problem:
if ($self->single_version and $version < $distver) {
$self->log("ERROR: $pmFile: $version needs to be updated");
return 1;
}

# If the module hasn't been committed yet, it needs updating:
# (since it doesn't match the dist version)
if ($modifiedRef->{$pmFile}) {
Expand Down

0 comments on commit 67d626f

Please sign in to comment.