App-GitGot

 view release on metacpan or  search on metacpan

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


sub _parse_github_identity {
  my $file = path( File::HomeDir::Tiny::home() , '.github-identity' );

  $file->exists or
    say STDERR "ERROR: Can't find $file" and exit(1);

  my @lines = $file->lines;

  my %config;
  foreach ( @lines ) {
    chomp;
    next unless $_;
    my( $k , $v ) = split /\s/;
    $config{$k} = $v;
  }

  if ( defined $config{access_token} ) {
    return ( access_token => $config{access_token} )
  }
  elsif ( defined $config{pass} and defined $config{user} ) {
    return ( login => $config{user} , pass => $config{pass} )
  }
  else {
    say STDERR "Couldn't parse password or access_token info from ~/.github-identity"
      and exit(1);
  }
}

sub _parse_github_url {
  my $url = shift;

  my( $owner , $repo ) = $url =~ m|/github.com/([^/]+)/([^/]+?)(?:\.git)?$|
    or say STDERR "ERROR: Can't parse '$url'.\nURL needs to be of the form 'github.com/OWNER/REPO'.\n"
    and exit(1);

  return( $owner , $repo );
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::GitGot::Command::fork - fork a github repo

=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.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut



( run in 0.527 second using v1.01-cache-2.11-cpan-9581c071862 )