diff --git a/CHANGELOG.yml b/CHANGELOG.yml index 1c22df7..18f6487 100644 --- a/CHANGELOG.yml +++ b/CHANGELOG.yml @@ -4,6 +4,12 @@ project: homepage: https://git.babyl.ca/yanick/App-Changelord with_stats: 1 releases: + - version: NEXT + date: ~ + changes: + - commit: b25e98fc57307fbede9382b31fd85f3cbbc72cf7 + desc: ' test was expecting to be in a git repo' + type: fix - version: v0.0.1 date: 2022-06-25 changes: diff --git a/lib/App/Changelord/Command/Bump.pm b/lib/App/Changelord/Command/Bump.pm index ddea6ac..685a4aa 100644 --- a/lib/App/Changelord/Command/Bump.pm +++ b/lib/App/Changelord/Command/Bump.pm @@ -18,7 +18,7 @@ use Version::Dotted::Semantic; with 'App::Changelord::Role::Changelog'; with 'App::Changelord::Role::ChangeTypes'; with 'App::Changelord::Role::Versions'; -with 'App::Changelord::Role::Stats'; +with 'App::Changelord::Role::GitRepo'; sub run ($self) { my $bump = shift @ARGV; diff --git a/lib/App/Changelord/Command/GitGather.pm b/lib/App/Changelord/Command/GitGather.pm index 94385fa..966a215 100644 --- a/lib/App/Changelord/Command/GitGather.pm +++ b/lib/App/Changelord/Command/GitGather.pm @@ -39,16 +39,11 @@ capture a C and C as well. END_POD use Path::Tiny; -use Git::Repository; with 'App::Changelord::Role::Changelog'; with 'App::Changelord::Role::Versions'; with 'App::Changelord::Role::ChangeTypes'; - -has repo => ( - is => 'ro', - default => sub { Git::Repository->new( work_tree => '.' ) }, -); +with 'App::Changelord::Role::GitRepo'; has commit_regex => ( is => 'lazy' diff --git a/lib/App/Changelord/Role/Stats.pm b/lib/App/Changelord/Role/GitRepo.pm similarity index 83% rename from lib/App/Changelord/Role/Stats.pm rename to lib/App/Changelord/Role/GitRepo.pm index c80b99e..b1b0563 100644 --- a/lib/App/Changelord/Role/Stats.pm +++ b/lib/App/Changelord/Role/GitRepo.pm @@ -1,4 +1,4 @@ -package App::Changelord::Role::Stats; +package App::Changelord::Role::GitRepo; use v5.36.0; @@ -13,12 +13,13 @@ requires 'changelog'; # stolen from Dist::Zilla::Plugin::ChangeStats::Git has repo => ( - is => 'ro', - default => sub { Git::Repository->new( work_tree => '.' ) }, + is => 'lazy', + default => sub { + Git::Repository->new( work_tree => '.' ) + }, ); -has stats => ( - is => 'lazy' ); +has stats => ( is => 'lazy' ); sub _build_stats ($self) { my $comparison_data = $self->_get_comparison_data or return; diff --git a/t/stats.t b/t/stats.t index c448aa7..02741b1 100644 --- a/t/stats.t +++ b/t/stats.t @@ -15,12 +15,22 @@ package TestMe { }} ); - with 'App::Changelord::Role::Stats'; + with 'App::Changelord::Role::GitRepo'; with 'App::Changelord::Role::ChangeTypes'; } -my $test = TestMe->new; +package TestRepo { + use Moo; + + sub run(@args) { + return 'blah blah'; + } +} + +my $test = TestMe->new( + repo => TestRepo->new, +); like $test->stats => qr/code churn: /;