Skip to content

Commit

Permalink
Tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
kentfredric committed May 30, 2012
1 parent 474f772 commit 4822502
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
18 changes: 11 additions & 7 deletions example/ls_sha1_as_commit.pl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

use Path::Class qw( dir );


my $cwd = dir( q{.} );

sub is_git_dir {
Expand Down Expand Up @@ -41,6 +40,7 @@ sub find_git_dir {
sub trim {
my $comment = shift;
$comment =~ s/\s+/ /g;

#if ( length( $comment ) > 80 ) {
# return substr( $comment, 0, 80 ) . '...';
#}
Expand All @@ -57,22 +57,26 @@ sub abbr_sha {
use CPAN::Changes::Release;
my $release = CPAN::Changes::Release->new(
version => '1.0',
date => '2012-05-30',
date => '2012-05-30',

);

my $walker = Git::PurePerl::Walker->new(
repo => $repo,
method => 'FirstParent::FromHEAD',
on_commit => sub {
my $commit = shift;
$release->add_changes( { group => 'Git::Changes' }, sprintf "%s %s (%s)", abbr_sha( $commit->sha1 ), trim( $commit->comment ), $commit->author->name);
my $commit = shift;
$release->add_changes(
{ group => 'Git::Changes' },
sprintf "%s %s (%s)",
abbr_sha( $commit->sha1 ),
trim( $commit->comment ),
$commit->author->name
);
},
);

$walker->step_all;
my $changes = CPAN::Changes->new(
preamble => "Revision History for \$Project",
);
my $changes = CPAN::Changes->new( preamble => "Revision History for \$Project", );
$changes->add_release( $release );
print $changes->serialize();
17 changes: 8 additions & 9 deletions lib/Git/PurePerl/Walker/Method/FirstParent/FromHEAD.pm
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ L<< C<Git::PurePerl::B<Walker::Method::FirstParent>-E<gt>I<_commit( $commit_obje
=cut

has '+start' => (
init_arg => undef,
lazy_build => 1,
required => 0,
init_arg => undef,
lazy_build => 1,
required => 0,
);

=p_attrmethod _has_repo
Expand All @@ -62,12 +62,12 @@ has '+_repo' => ( predicate => '_has_repo', );
=cut

sub _build_start {
my $self = shift;
if ( not $self->_has_repo ) {
my $self = shift;
if ( not $self->_has_repo ) {
require Carp;
Carp::confess('No repo defined while trying to find a starting commit');
}
return $self->_repo->head_sha1;
Carp::confess( 'No repo defined while trying to find a starting commit' );
}
return $self->_repo->head_sha1;
}

=imethod _build_commit
Expand Down Expand Up @@ -109,4 +109,3 @@ L<< C<Git::PurePerl::B<Walker::Method::FirstParent>-E<gt>I<reset()>>|Git::PurePe
no Moose;
__PACKAGE__->meta->make_immutable;
1;

2 changes: 1 addition & 1 deletion t/0201_firstparent_fromhead.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ my $expected = {
};

my $method_factory = Git::PurePerl::Walker::Method::FirstParent::FromHEAD->new();
my $method = $method_factory->for_repository( $repo );
my $method = $method_factory->for_repository( $repo );

is( $method->_commit->sha1, $expected->{ HEAD }, 'At Head' );
is( $method->current->sha1, $expected->{ HEAD }, 'At Head' );
Expand Down

0 comments on commit 4822502

Please sign in to comment.