Dist-Zilla-PluginBundle-GitLab
view release on metacpan or search on metacpan
lib/Dist/Zilla/Plugin/GitLab/Create.pm view on Meta::CPAN
return if not $repo;
my $git_dir = "$root/.git";
my $rem_ref = $git_dir . '/refs/remotes/' . $self->remote;
if ( ( -d $git_dir ) && ( not -d $rem_ref ) ) {
my $git = Git::Wrapper->new($root);
$self->log( [ 'Setting GitLab remote \'%s\'', $self->remote ] );
$git->remote( 'add', $self->remote, $repo->{ssh_url_to_repo} );
my ($branch) = try {
$git->rev_parse( { abbrev_ref => 1, symbolic_full_name => 1 },
'HEAD' )
};
if ($branch) {
try {
$git->config("branch.$branch.merge");
$git->config("branch.$branch.remote");
}
catch {
$self->log(
[ 'Setting up remote tracking for branch \'%s\'', $branch ] );
$git->config( "branch.$branch.merge", "refs/heads/$branch" );
$git->config( "branch.$branch.remote", $self->remote );
};
}
}
}
sub _confirm {
my ($self) = @_;
my $dist = $self->zilla->name;
my $prompt = "Shall I create a GitLab repository for $dist?";
return $self->zilla->chrome->prompt_yn( $prompt, { default => 1 } );
}
__PACKAGE__->meta->make_immutable;
1;
=pod
=encoding UTF-8
=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>:
# default config
[GitLab::Create]
# to override publicness
[GitLab::Create]
public = 0
# use a template for the repository name
[GitLab::Create]
repo = {{ lc $dist->name }}
See L</ATTRIBUTES> for more options.
=head1 DESCRIPTION
This Dist::Zilla plugin creates a new git repository on GitLab.com when
a new distribution is created with C<dzil new>.
It will also add a new git remote pointing to the newly created GitLab
repository's private URL. See L</"ADDING REMOTE"> for more info.
=head1 ATTRIBUTES
=over
=item C<issues>
Enable issues for the new repository if this option is set to true (default).
=item C<merge_requests>
Enable merge requests for the new repository if this option is set to true (default).
=item C<namespace>
Specifies the project namespace path in which to create the repository
(by default the repository is created in the user's account).
=item C<packages>
Enable packages for the new repository if this option is set to true (default).
=item C<prompt>
Prompt for confirmation before creating a GitLab repository if this option is
set to true (default is false).
=item C<public>
Create a public repository if this option is set to true (default), otherwise
( run in 1.681 second using v1.01-cache-2.11-cpan-39bf76dae61 )