File: push-gitconfig.t

package info (click to toggle)
libdist-zilla-plugin-git-perl 2.051-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 712 kB
  • sloc: perl: 1,306; makefile: 11
file content (70 lines) | stat: -rw-r--r-- 1,949 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use strict;
use warnings;

use Git::Wrapper;
use Path::Tiny qw(path);
use Test::More 0.88;            # done_testing
use Test::Fatal qw(exception);

use lib 't/lib';
use Util;

eval { require Dist::Zilla::Plugin::Config::Git };
plan skip_all => 'Dist::Zilla::Plugin::Config::Git not installed'
    if $@ and $@ !~ /^Can't locate /;

skip_unless_git_version('2.4.1'); # for push.followTags

plan tests => 7;

init_test(corpus => 'push-gitconfig');

$git->add( qw{ dist.ini Changes } );
$git->commit( { message => 'initial commit' } );

# create a clone, and use it to set up 'genesis'
my $clone = $base_dir->child('clone');
$git->clone( { quiet=>1, 'no-checkout'=>1, bare=>1 }, "$git_dir", "$clone" );
$git->remote('add', 'genesis', "$clone");
$git->config('branch.master.remote', 'genesis');
$git->config('branch.master.merge', 'refs/heads/master');

# do the release
append_to_file('Changes',  "\n");
append_to_file('dist.ini', "\n");

new_zilla_from_repo;
$zilla->release;

# Check log
zilla_log_is('Git::Push', <<'');
[Git::Push] pushing to genesis master:master

# check if everything was pushed
$git = Git::Wrapper->new( "$clone" );
my ($log) = $git->log( 'HEAD' );
like( $log->message, qr/v1.23\n[^a-z]*foo[^a-z]*bar[^a-z]*baz/, 'commit pushed' );

# check if tag has been correctly created
my @tags = $git->tag;
is( scalar(@tags), 1, 'one tag pushed' );
is( $tags[0], 'v1.23', 'new tag created after new version' );

# try a release with a bogus remote
append_to_file('dist.ini', <<'END dist.ini');
push_to = bogus unmodified
END dist.ini

new_zilla_from_repo;
my $exception = exception { $zilla->release };
like($exception, qr/^\Q[Git::Push] These remotes do not exist: bogus\E/,
     'Caught bogus remote');

zilla_log_is('Git::Push', <<'');
[Git::Push] These remotes do not exist: bogus

is_deeply($zilla->plugin_named('Git::Push')->push_to,
          [ 'bogus unmodified' ],
          "git_config->push_to is overridden");

done_testing;