App-KGB
view release on metacpan or search on metacpan
t/53-client-git-merges.t view on Meta::CPAN
password => "hidden", # not used by this client instance
}
),
],
#br_mod_re => \@br_mod_re,
#br_mod_re_swap => $br_mod_re_swap,
#ignore_branch => $ignore_branch,
git_dir => $remote,
reflog => "$dir/reflog",
}
]
);
sub push_ok {
write_tmp 'reflog', '';
unlink $hook_log if $hook_log and -s $hook_log;
my $ignore = $git->command( [qw( push origin --all )], { STDERR => 0 } );
$ignore = $git->command( [qw( push origin --tags )], { STDERR => 0 } );
$c->_reset;
$c->_detect_commits;
diag `cat $hook_log` if $hook_log and -s $hook_log;
}
my %commits;
sub do_commit {
my $ignore = $git->command_oneline( 'commit', '-m', shift ) =~ /\[(\w+).*\s+(\w+)\]/;
push @{ $commits{$1} }, $2;
diag "commit $2 in branch $1" unless $tmp_cleanup;
}
my $commit;
###### first commit
w( 'old', 'content' );
$ign = $git->command( 'add', '.' );
do_commit('import old content');
$ign = $git->command( 'remote', 'add', 'origin', "file://$remote" );
push_ok;
$commit = $c->describe_commit;
ok( defined($commit), 'initial import commit' );
is( $c->describe_commit, undef, 'no more commits' );
TestBot->expect( "dummy/#test 12test/03there 05master "
. $commit->id
. " 06Test U. Ser (06ser) 03old import old content * 14http://scm.host.org/there/master/?commit="
. $commit->id.'' );
#### branch, two changes, merge. then the changes should be reported only once
my $b1 = 'a-new';
$ign = $git->command( [ 'checkout', '-b', $b1, 'master' ],
{ STDERR => 0 } );
w( 'new', 'content' );
$ign = $git->command( 'add', 'new' );
$ign = $git->command( 'commit', '-m', 'created new content' );
w( 'new', 'more content' );
$ign = $git->command( 'commit', '-a', '-m', 'updated new content' );
$ign = $git->command( 'checkout', '-q', 'master' );
$ign = $git->command( 'merge', '--no-ff', '-m', "merge '$b1' into master", $b1 );
# same with a branch name sorting after 'master'
my $b2 = 'new-content';
$ign = $git->command( [ 'checkout', '-b', $b2, 'master' ],
{ STDERR => 0 } );
w( 'new', 'content' );
$ign = $git->command( 'add', 'new' );
$ign = $git->command( 'commit', '-m', 'created new content' );
w( 'new', 'more content' );
$ign = $git->command( 'commit', '-a', '-m', 'updated new content' );
$ign = $git->command( 'checkout', '-q', 'master' );
$ign = $git->command( 'merge', '--no-ff', '-m', "merge '$b2' into master", $b2 );
push_ok();
$commit = $c->describe_commit;
ok( defined($commit), 'merge commit exists' );
is( $commit->branch, 'master' );
is( $commit->log, "merge '$b1' into master" );
TestBot->expect( 'dummy/#test 12test/03there 05master '
. $commit->id
. ' 06Test U. Ser (06ser) merge \'a-new\' into master * 14http://scm.host.org/there/master/?commit='
. $commit->id
. '' );
$commit = $c->describe_commit;
ok( defined($commit), 'merge commit exists' );
is( $commit->branch, 'master' );
is( $commit->log, "merge '$b2' into master" );
TestBot->expect( 'dummy/#test 12test/03there 05master '
. $commit->id
. ' 06Test U. Ser (06ser) merge \'new-content\' into master * 14http://scm.host.org/there/master/?commit='
. $commit->id
. '' );
$commit = $c->describe_commit;
ok( defined($commit), "first $b1 commit exists" );
is( $commit->branch, $b1 );
is( $commit->log, "created new content" );
TestBot->expect( 'dummy/#test 12test/03there 05a-new '
. $commit->id
. ' 06Test U. Ser (06ser) 03new created new content * 14http://scm.host.org/there/a-new/?commit='
. $commit->id
. '' );
$commit = $c->describe_commit;
ok( defined($commit), "second $b1 commit exists" );
is( $commit->branch, $b1 );
is( $commit->log, "updated new content" );
TestBot->expect( 'dummy/#test 12test/03there 05a-new '
. $commit->id
. ' 06Test U. Ser (06ser) 10new updated new content * 14http://scm.host.org/there/a-new/?commit='
. $commit->id
. '' );
$commit = $c->describe_commit;
ok( defined($commit), "first $b2 commit exists" );
is( $commit->branch, $b2 );
is( $commit->log, "created new content" );
TestBot->expect( 'dummy/#test 12test/03there 05new-content '
. $commit->id
. ' 06Test U. Ser (06ser) 10new created new content * 14http://scm.host.org/there/new-content/?commit='
. $commit->id
. '' );
$commit = $c->describe_commit;
ok( defined($commit), "second $b2 commit exists" );
is( $commit->branch, $b2 );
is( $commit->log, "updated new content" );
TestBot->expect( 'dummy/#test 12test/03there 05new-content '
. $commit->id
. ' 06Test U. Ser (06ser) 10new updated new content * 14http://scm.host.org/there/new-content/?commit='
. $commit->id
. '' );
##### No more commits after the last
$commit = $c->describe_commit;
is( $commit, undef );
my $output = $test_bot->get_output;
undef($test_bot); # make sure all output us there
eq_or_diff( $output, TestBot->expected_output );
done_testing();
( run in 1.749 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )