Dist-Zilla-PluginBundle-Codeberg
view release on metacpan or search on metacpan
lib/Dist/Zilla/Plugin/Codeberg/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 Codeberg 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 Codeberg 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::Codeberg::Create - Create a new Codeberg repo on dzil new
=head1 VERSION
version 2.0100
=head1 SYNOPSIS
Configure git with your Codeberg credentials:
$ git config --global codeberg.user LoginName
$ git config --global codeberg.token AccessToken
Alternatively you can install L<Config::Identity> and write your credentials
in the (optionally GPG-encrypted) C<~/.codeberg> file as follows:
login LoginName
token AccessToken
Set up an access token on Codeberg, in your profile under "Personal Access Tokens." You
must grant the token the C<api> scope!
then, in your F<profile.ini>:
# default config
[Codeberg::Create]
# to override publicness
[Codeberg::Create]
public = 0
# use a template for the repository name
[Codeberg::Create]
repo = {{ lc $dist->name }}
See L</ATTRIBUTES> for more options.
=head1 DESCRIPTION
This Dist::Zilla plugin creates a new git repository on Codeberg.org when
a new distribution is created with C<dzil new>.
It will also add a new git remote pointing to the newly created Codeberg
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 Codeberg 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.091 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )