Dist-Zilla-PluginBundle-GitLab
    
    
  
  
  
view release on metacpan or search on metacpan
README.mkdn view on Meta::CPAN
# NAME
Dist::Zilla::PluginBundle::GitLab - Access GitLab functionality to maintain distros from Dist::Zilla
# VERSION
version 1.0002
# SYNOPSIS
Configure git with your GitLab credentials:
    $ git config --global gitlab.user LoginName
    $ git config --global gitlab.token AccessToken
Alternatively you can install [Config::Identity](https://metacpan.org/pod/Config%3A%3AIdentity) and write your credentials
in the (optionally GPG-encrypted) `~/.gitlab` file as follows:
    login LoginName
    token AccessToken
Set up an access token on GitLab, in your profile under "Personal Access Tokens." You
must grant the token the `api` scope!
then, in your `dist.ini`:
lib/Dist/Zilla/Plugin/GitLab.pm view on Meta::CPAN
   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 {
lib/Dist/Zilla/Plugin/GitLab.pm view on Meta::CPAN
         ? 'Err: missing value \'user\' in ~/.gitlab'
         : 'Err: Missing value \'gitlab.user\' in git config';
      $self->log($error);
      return undef;
   }
   return $login;
}
sub _build_credentials {
   my $self = shift;
   my ( $login, $token );
   $login = $self->_login;
   if ( !$login ) {
      return {};
   }
   my %identity;
lib/Dist/Zilla/Plugin/GitLab.pm view on Meta::CPAN
      $token = $identity{token};
   }
   else {
      $token = qx{git config gitlab.token};
      chomp $token;
   }
   return { login => $login, token => $token };
}
sub _has_credentials {
   my $self = shift;
   return keys %{ $self->_credentials };
}
sub _auth_headers {
   my $self = shift;
   my $credentials = $self->_credentials;
   my %headers = ();
   if ( $credentials->{token} ) {
      $headers{'PRIVATE-TOKEN'} = $credentials->{token};
   }
   return \%headers;
}
sub _get_repo_name {
   my ( $self, $login ) = @_;
   my $repo;
   my $git = Git::Wrapper->new('./');
lib/Dist/Zilla/Plugin/GitLab/Create.pm view on Meta::CPAN
=head1 NAME
Dist::Zilla::Plugin::GitLab::Create - Create a new GitLab repo on dzil new
=head1 VERSION
version 1.0002
=head1 SYNOPSIS
Configure git with your GitLab credentials:
    $ git config --global gitlab.user LoginName
    $ git config --global gitlab.token AccessToken
Alternatively you can install L<Config::Identity> and write your credentials
in the (optionally GPG-encrypted) C<~/.gitlab> file as follows:
    login LoginName
    token AccessToken
Set up an access token on GitLab, in your profile under "Personal Access Tokens." You
must grant the token the C<api> scope!
then, in your F<profile.ini>:
lib/Dist/Zilla/Plugin/GitLab/Update.pm view on Meta::CPAN
use JSON::MaybeXS;
use Moose;
use List::Util qw(first);
use URL::Encode qw(url_encode_utf8);
extends 'Dist::Zilla::Plugin::GitLab';
with 'Dist::Zilla::Role::AfterRelease';
sub after_release {
   my $self = shift;
   return if ( !$self->_has_credentials );
   my $repo_name = $self->_get_repo_name( $self->_credentials->{login} );
   if ( not $repo_name ) {
      $self->log('cannot update GitLab repository info');
      return;
   }
   my $params = {
      name        => ( $repo_name =~ /\/(.*)$/ )[0],
      description => $self->zilla->abstract,
   };
lib/Dist/Zilla/PluginBundle/GitLab.pm view on Meta::CPAN
=head1 NAME
Dist::Zilla::PluginBundle::GitLab - Access GitLab functionality to maintain distros from Dist::Zilla
=head1 VERSION
version 1.0002
=head1 SYNOPSIS
Configure git with your GitLab credentials:
    $ git config --global gitlab.user LoginName
    $ git config --global gitlab.token AccessToken
Alternatively you can install L<Config::Identity> and write your credentials
in the (optionally GPG-encrypted) C<~/.gitlab> file as follows:
    login LoginName
    token AccessToken
Set up an access token on GitLab, in your profile under "Personal Access Tokens." You
must grant the token the C<api> scope!
then, in your F<dist.ini>:
t/tests/dist/zilla/plugin/gitlab/update.t view on Meta::CPAN
use Test2::Tools::Explain;
use Test2::Tools::JSON;
use FindBin;
use lib "$FindBin::Bin/../lib";
use Path::Tiny;
use Test::DZil;
use Dist::Zilla::Plugin::GitLab;
my $mock_dist_zilla_plugin_gitlab = mock 'Dist::Zilla::Plugin::GitLab' => (
   override => [
      _build_credentials =>
         sub { return { login => 'bob', token => 'AbC00ToKeN' } },
      _get_repo_name => sub { return 'bob/My-Stuff' },
   ],
);
my $http_request;
use HTTP::Tiny;
my $mock_http_tiny = mock 'HTTP::Tiny' => (
   override => [
( run in 0.425 second using v1.01-cache-2.11-cpan-c333fce770f )