Dist-Zilla-PluginBundle-GitLab

 view release on metacpan or  search on metacpan

lib/Dist/Zilla/Plugin/GitLab.pm  view on Meta::CPAN

package Dist::Zilla::Plugin::GitLab 1.0002;

use Modern::Perl;
use JSON::MaybeXS;
use Moose;
use Try::Tiny;
use HTTP::Tiny;
use Git::Wrapper;
use Class::Load qw(try_load_class);

has api => (
   is      => 'ro',
   isa     => 'Str',
   default => 'https://gitlab.com/api/v4',
);

has remote => (
   is      => 'ro',
   isa     => 'Maybe[Str]',
   default => 'origin',
);

has repo => (
   is  => 'ro',
   isa => 'Maybe[Str]',
);

has _credentials => (
   is      => 'ro',
   isa     => 'HashRef',
   lazy    => 1,
   builder => '_build_credentials',
);

has _login => (
   is      => 'ro',
   isa     => 'Maybe[Str]',
   lazy    => 1,
   builder => '_build_login',
);

sub _build_login {
   my $self = shift;

   my ( $login, %identity );

   %identity = Config::Identity::GitLab->load
      if try_load_class('Config::Identity::GitLab');

   if (%identity) {
      $login = $identity{login};
   }
   else {
      $login = qx{git config gitlab.user};
      chomp $login;
   }

   if ( !$login ) {
      my $error
         = %identity
         ? 'Err: missing value \'user\' in ~/.gitlab'
         : 'Err: Missing value \'gitlab.user\' in git config';



( run in 0.640 second using v1.01-cache-2.11-cpan-437f7b0c052 )