Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

preparing for a first release

  • Loading branch information...
commit 17fa402b3f810312a167cec5b9443bdc0c78ad29 1 parent bd9d1ae
@yanick authored
View
2  .gitignore
@@ -1,2 +1,4 @@
+corpus
/Dist-Zilla-Plugin-ChangeStats-Git*
.build
+tmp
View
2  MANIFEST.SKIP
@@ -1,3 +1,5 @@
+tmp
+corpus
^dist.ini
^MANIFEST.SKIP
Dist-Zilla-Plugin-ChangeStats-Git.*
1  corpus
@@ -1 +0,0 @@
-Subproject commit 411f47ef495c00945a2d99c37a199018d0f3a9d2
View
30 lib/Dist/Zilla/Plugin/ChangeStats/Git.pm
@@ -1,10 +1,26 @@
package Dist::Zilla::Plugin::ChangeStats::Git;
-# ABSTRACT:
+# ABSTRACT: add code churn statistics to the changelog
=head1 SYNOPSIS
+ In the dist.ini:
+
+ [ChangeStats::Git]
+ group=STATISTICS
+
=head1 DESCRIPTION
+Adds a line to the changelog giving some stats about the
+code churn since the last release, which will look like:
+
+ - code churn: 6 files changed, 111 insertions(+), 1 deletions(-)
+
+=head1 ARGUMENTS
+
+=head2 group
+
+If given, the line is added to the specified group.
+
=cut
use strict;
@@ -25,7 +41,6 @@ with 'Dist::Zilla::Role::Author::YANICK::RequireZillaRole' => {
roles => [ qw/ Author::YANICK::Changelog / ],
};
-
has repo => (
is => 'ro',
default => sub { Git::Repository->new( work_tree => '.' ) },
@@ -36,20 +51,25 @@ has change_file => (
default => 'Changes',
);
+has group => (
+ is => 'ro',
+ default => '',
+);
+
sub munge_files {
my ($self) = @_;
my @output = $self->repo->run( 'log', '--stat', 'releases..master' );
# actually, only the last line is interesting
- my $stats = "stats: " . $output[-1];
+ my $stats = "code churn: " . $output[-1];
+ $stats =~ s/\s+/ /g;
my ( $next ) = reverse $self->zilla->changes->releases;
- $next->add_changes( $stats );
+ $next->add_changes( { group => $self->group }, $stats );
}
-
__PACKAGE__->meta->make_immutable;
no Moose;
View
3  lib/Dist/Zilla/Role/Author/YANICK/Changelog.pm
@@ -49,8 +49,7 @@ sub set_changelog_auto_update {
sub save_changelog {
my $self = shift;
- warn 'saving...';
- warn $self->changes->serialize;
+ #warn $self->changes->serialize;
$self->changelog_file->content($self->changes->serialize);
}
View
20 t/basic.t
@@ -1,7 +1,9 @@
use strict;
use warnings;
-use Test::More tests => 5;
+use Test::More; tests => 5;
+
+plan skip_all => 'coming soon';
use Test::DZil;
@@ -21,13 +23,17 @@ my $dist_ini = dist_ini({
my $tzil = Builder->from_config(
{ dist_root => 'corpus' },
- {
- 'source/dist.ini' => $dist_ini
- },
- );
+ # {
+ # 'source/dist.ini' => $dist_ini
+ # },
+);
$tzil->build;
like $tzil->slurp_file('build/Changes'),
- qr/XXX/,
- "regular change, count as minor change";
+ qr/
+\[STATISTICS\]\s*\n
+\s*-\s*code\schurn:\s+\d+\sfiles\schanged,
+\s\d+\sinsertions\(\+\),\s\d+\sdeletions\(-\)
+ /x,
+ "stats added";
Please sign in to comment.
Something went wrong with that request. Please try again.