Dist-Zilla-PluginBundle-Codeberg
view release on metacpan or search on metacpan
lib/Dist/Zilla/Plugin/Codeberg.pm view on Meta::CPAN
package Dist::Zilla::Plugin::Codeberg 2.0100;
use Modern::Perl;
use JSON::MaybeXS;
use Moose;
use Try::Tiny;
use HTTP::Tiny;
use Git::Wrapper;
use Class::Load qw(try_load_class);
our $AUTHORITY = 'cpan:GEEKRUTH'; # AUTHORITY
has api => (
is => 'ro',
isa => 'Str',
default => 'https://codeberg.org/api/v1',
);
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::Codeberg->load
if try_load_class('Config::Identity::Codeberg');
if (%identity) {
$login = $identity{login};
}
else {
$login = qx{git config codeberg.user};
chomp $login;
}
if ( !$login ) {
my $error
= %identity
? 'Err: missing value \'user\' in ~/.codeberg'
: 'Err: Missing value \'codeberg.user\' in git config';
( run in 0.452 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )