Dist-Zilla-PluginBundle-Codeberg
view release on metacpan or search on metacpan
README.mkdn view on Meta::CPAN
# NAME
Dist::Zilla::PluginBundle::Codeberg - Access Codeberg functionality to maintain distros from Dist::Zilla
# VERSION
version 2.0100
# SYNOPSIS
Configure git with your Codeberg credentials:
$ git config --global codeberg.user LoginName
$ git config --global codeberg.token AccessToken
Alternatively you can install [Config::Identity](https://metacpan.org/pod/Config%3A%3AIdentity) and write your credentials
in the (optionally GPG-encrypted) `~/.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 `api` scope!
then, in your `dist.ini`:
lib/Dist/Zilla/Plugin/Codeberg.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/Codeberg.pm view on Meta::CPAN
? 'Err: missing value \'user\' in ~/.codeberg'
: 'Err: Missing value \'codeberg.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/Codeberg.pm view on Meta::CPAN
$token = $identity{token};
}
else {
$token = qx{git config codeberg.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{'Authorization'} = 'token ' . $credentials->{token};
}
return \%headers;
}
sub _get_repo_name {
my ( $self, $login ) = @_;
my $repo;
my $git = Git::Wrapper->new('./');
lib/Dist/Zilla/Plugin/Codeberg/Create.pm view on Meta::CPAN
=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>:
lib/Dist/Zilla/Plugin/Codeberg/Update.pm view on Meta::CPAN
use List::Util qw(first);
use URL::Encode qw(url_encode_utf8);
our $AUTHORITY = 'cpan:GEEKRUTH'; # AUTHORITY
extends 'Dist::Zilla::Plugin::Codeberg';
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 Codeberg repository info');
return;
}
my $params = {
name => ( $repo_name =~ /\/(.*)$/ )[0],
description => $self->zilla->abstract,
};
lib/Dist/Zilla/PluginBundle/Codeberg.pm view on Meta::CPAN
=head1 NAME
Dist::Zilla::PluginBundle::Codeberg - Access Codeberg functionality to maintain distros from Dist::Zilla
=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<dist.ini>:
t/tests/dist/zilla/plugin/codeberg/update.t view on Meta::CPAN
use Test2::Tools::JSON;
use FindBin;
use lib "$FindBin::Bin/../lib";
use Path::Tiny;
use Test::DZil;
use Dist::Zilla::Plugin::Codeberg;
my $mock_dist_zilla_plugin_codeberg
= mock 'Dist::Zilla::Plugin::Codeberg' => (
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 1.137 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )