Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'fix-commit-count'
  • Loading branch information
genehack committed Sep 18, 2016
2 parents d03c003 + f589010 commit 3a21659
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Changes
Expand Up @@ -2,6 +2,8 @@ Revision history for {{$dist->name}}

{{$NEXT}}

Properly track commits in test (Graham Knop)

0.046 2016-09-12 20:13:04-07:00 America/Los_Angeles

No changes since last development release.
Expand Down
17 changes: 12 additions & 5 deletions t/basic.t
Expand Up @@ -54,8 +54,10 @@ SKIP: {
is( $git->status->is_dirty , 1 , 'repo is dirty' );
}

my $commit_count = 0;
my $time = time;
$git->commit({ message => "FIRST\n\n\tBODY\n" });
$commit_count++;

SKIP: {
skip 'testing old git without porcelain' , 1 unless $git->supports_status_porcelain;
Expand Down Expand Up @@ -130,6 +132,7 @@ SKIP: {

$git->RUN('mv', 'foo/bar', 'foo/bar-moved');
$git->commit({ message => "move a file" });
$commit_count++;

my @second_raw_log = $git->log({ raw => 1, follow => 1 }, '-n1', '--', 'foo/bar-moved');
is(@second_raw_log, 1, 'still one raw log entry');
Expand All @@ -142,10 +145,15 @@ SKIP: {
system("cp $dir/foo/bar-moved $dir/foo/barbar");
$git->add('foo/barbar');
$git->commit({ message => 'copy a file'});
$commit_count++;

my @third_raw_log = $git->log({ raw => 1, follow => 1}, '-n1', '--', 'foo/barbar');
is(@third_raw_log, 1, 'one for the third time');


if ( versioncmp( $git->version , '1.7.2') eq -1 ) {
skip "testing old git that can't track copies with --follow", 3;
}
my($next_raw_mod_obj) = $third_raw_log[0]->modifications;
is($next_raw_mod_obj->score(), 100, 'expected copy score');
is($next_raw_mod_obj->type(), 'C', 'expected copy type');
Expand All @@ -167,8 +175,6 @@ sub _timeout (&) {
return $timeout;
}

my $commit_count = 2;

SKIP: {
if ( versioncmp( $git->version , '1.7.0.5') eq -1 ) {
skip 'testing old git without commit --allow-empty-message support' , 1;
Expand All @@ -185,6 +191,7 @@ SKIP: {

$timeout = _timeout {
$git->commit({ message => "", 'allow-empty-message' => 1 });
$commit_count++;
};

if ( $@ && !$timeout ) {
Expand All @@ -193,12 +200,12 @@ SKIP: {
}

@log = $git->log();
is(@log, 4, 'four log entries, one with empty commit message');
$commit_count+=2;
is(@log, $commit_count, "$commit_count log entries, one with empty commit message");
};

my @out = $git->RUN('log','--format=%H');
ok scalar @out == $commit_count, q{using RUN('log','--format=%H') to get all four commit SHAs};
is scalar @out, $commit_count,
q{using RUN('log','--format=%H') to get all $commit_count commit SHAs};

# test --message vs. -m
my @arg_tests = (
Expand Down

0 comments on commit 3a21659

Please sign in to comment.