App-GitGot

 view release on metacpan or  search on metacpan

lib/App/GitGot/Command/fork.pm  view on Meta::CPAN

120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
=head1 VERSION
 
version 1.339
 
=head1 SYNOPSIS
 
    # fork repo on GitHub, then clone repository and add to got config
    $ got fork github.com/owner/repo
 
    # fork repo on GitHub, add to got config, but do _not_ clone locally
    $ got fork -n github.com/owner/repo
    $ got fork --noclone github.com/owner/repo
 
=head1 AUTHOR
 
John SJ Anderson <john@genehack.org>
 
=head1 COPYRIGHT AND LICENSE
 
This software is copyright (c) 2020 by John SJ Anderson.

t/02-add.t  view on Meta::CPAN

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
  my $result = test_app( 'App::GitGot' => [ 'add' ]);
 
  is   $result->stdout    , ''                              , 'empty STDOUT';
  like $result->stderr    , qr/Non-git repos not supported/ , 'expected error on STDERR';
  is   $result->exit_code , 1                               , 'exit with 1';
}
 
my $config = "$dir/gitgot";
file_not_exists_ok $config , 'no config';
 
Test::BASE::build_fake_git_repo();
 
{
  my $result = test_app( 'App::GitGot' => [ 'add' , '-f' , $config  , '-D' ]);
 
  like $result->stdout, qr/
        Add \s repository \s at \s '.*?'\? \s+ \(y\/n\) \s \[y\]: \s y \s+
        Name\? \s+ \[foo.git\]: \s+ foo.git \s+
        Tracking \s remote\? \s+  : \s+

t/04-clone.t  view on Meta::CPAN

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
 
use YAML              qw/ LoadFile /;
 
my $dir    = Test::BASE::create_tempdir_and_chdir();
my $config = path( "$dir/gitgot" );
file_not_exists_ok $config , 'config does not exist';
 
$ENV{GITGOT_FAKE_GIT_WRAPPER} = 1;
 
{
  my $result = test_app( 'App::GitGot' => [ 'clone' , '-f' , $config ]);
 
  is   $result->stdout    , '' , 'nothing on STDOUT';
  like $result->stderr    ,
    qr/ERROR: Need the URL to clone/ ,
    'need to give a URL';
  is   $result->exit_code , 1  , 'exit with 1';
 
  file_not_exists_ok $config , 'failed command does not create config';
}
 
{
  my $result = test_app( 'App::GitGot' => [ 'clone' , '-f' , $config , '-Dq' ,
                                            'http://genehack.org/fake-git-repo.git' ]);
 
  is $result->stdout    , '' , 'no output';
  is $result->stderr    , '' , 'nothing on STDERR';
  is $result->exit_code , 0  , 'exit with 0';

t/05-fork.t  view on Meta::CPAN

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
71
72
73
74
75
76
77
78
79
  $mock->mock( create_fork => sub {{ ssl_url => 'yeahboi' }} );
}
 
use YAML              qw/ LoadFile /;
 
my $dir    = Test::BASE::create_tempdir_and_chdir();
my $config = path( "$dir/gitgot" );
file_not_exists_ok $config , 'config does not exist';
 
$ENV{HOME} = $dir;
 
{
  my $result = test_app( 'App::GitGot' => [ 'fork' , '-f' , $config ]);
 
  is   $result->stdout    , '' , 'nothing on STDOUT';
  like $result->stderr    ,
    qr/ERROR: Need the URL of a repo to fork/ ,
    'need to give a URL';
  is   $result->exit_code , 1  , 'exit with 1';
 
  file_not_exists_ok $config , 'failed command does not create config';
}
 
{
  my $result = test_app( 'App::GitGot' => [ 'fork' , '-f' , $config ,
                                            'http://not.github.org/' ]);
  is   $result->stdout    , '' , 'nothing on STDOUT';
  like $result->stderr    ,
    qr|ERROR: Can't parse 'http://not.github.org/'| ,
      'need repo URL';
  is   $result->exit_code , 1  , 'exit with 1';
 
  file_not_exists_ok $config , 'failed command does not create config';
}
 
Test::BASE::create_github_identity_file();
 
{
  my $result = test_app( 'App::GitGot' => [ 'fork' , '-f' , $config , 'http://not.github.org/' ]);
 
  is $result->stdout , '' , 'nothing on STDOUT';
  like $result->stderr ,
    qr|ERROR: Can't parse 'http://not.github.org| ,
      'need to give a *github* URL';
  is $result->exit_code , 1 , 'exit with 1';
 
  file_not_exists_ok $config , 'failed command does not create config';
}
 
{
  my $result = test_app( 'App::GitGot' => [ 'fork' , '-f' , $config , '--noclone' , '-q' ,
                                            'http://github.com/genehack/fake-git-repo.git' ]);
 
  is $result->stdout    , '' , 'no output';
  is $result->stderr    , '' , 'nothing on STDERR';
  is $result->exit_code , 0  , 'exit with 0';



( run in 0.279 second using v1.01-cache-2.11-cpan-bb97c1e446a )