Dist-Zilla-Plugin-GitHub

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

    from github
  - use https URLs for metacpan.org, p3rl.org
  - fix use of authentication tokens against latest github APIs

0.47      2018-09-16 22:43:24Z

  - Fix infinite loop when using 2FA (Joelle Maslak, #55)

0.46      2018-08-05 01:19:21Z

  - Fix error in calculating github credentials (Joelle Maslak, #52)
  - the 'cpan' option in [GitHub::Update] is now deprecated, and will now
    behave as if the 'metacpan' option was set instead.

0.45      2018-05-27 03:56:57Z

  - Authentication is optionally available for all requests, via the new
    'require_auth' option. (Dave Rolsky, #51)

0.44      2017-05-11 09:30:45Z

Changes  view on Meta::CPAN

 - Add proper command and usage description to the dzil gh command
 - Various fixes related to forked repositories

0.21      2012-06-08 10:53:12 Europe/Rome

 - Add 'gh' command to use the plugins from the dzil command-line

0.20      2012-06-06 19:16:05 Europe/Rome

 - Fix GitHub::Meta plugin on perl 5.8 (GH#13) (thanks, @berekuk!)
 - Optionally support Config::Identity::GitHub for retrieving credentials

0.19      2012-04-16 19:11:47 Europe/Rome

 - Add meta_home option (GH#12)

0.18      2012-04-10 10:21:09 Europe/Rome

 - Fix default value for fork (GH#10) (thanks, @ioanrogers!)
 - Switch to GitHub API v3 and discontinue token-based login
 - Improve error handling

lib/Dist/Zilla/Plugin/GitHub.pm  view on Meta::CPAN

    default => 0
);

has _login => (
    is      => 'ro',
    isa     => 'Maybe[Str]',
    lazy    => 1,
    builder => '_build_login',
);

has _credentials => (
    is => 'ro',
    isa => 'HashRef',
    lazy => 1,
    builder => '_build_credentials',
);

#pod =head1 DESCRIPTION
#pod
#pod B<Dist-Zilla-Plugin-GitHub> is a set of plugins for L<Dist::Zilla> intended
#pod to more easily integrate L<GitHub|https://github.com> in the C<dzil> workflow.
#pod
#pod The following is the list of the plugins shipped in this distribution:
#pod
#pod =over 4

lib/Dist/Zilla/Plugin/GitHub.pm  view on Meta::CPAN

            "Err: missing value 'user' in ~/.github" :
            "Err: Missing value 'github.user' in git config";

        $self->log($error);
        return undef;
    }

    return $login;
}

sub _build_credentials {
    my $self = shift;

    my ($login, $pass, $token);

    $login = $self->_login;

    if (!$login) {
        return {};
    }

lib/Dist/Zilla/Plugin/GitHub.pm  view on Meta::CPAN


    if (!$pass and !$token) {
        $pass = $self->zilla->chrome->prompt_str(
            "GitHub password for '$login'", { noecho => 1 },
        );
    }

    return { login => $login, pass => $pass, token => $token };
}

sub _has_credentials {
    my $self = shift;
    return keys %{$self->_credentials};
}

sub _auth_headers {
    my $self = shift;

    my $credentials = $self->_credentials;

    my %headers = ( Accept => 'application/vnd.github.v3+json' );
    if ($credentials->{pass}) {
        require MIME::Base64;
        my $basic = MIME::Base64::encode_base64("$credentials->{login}:$credentials->{pass}", '');
        $headers{Authorization} = "Basic $basic";
    }
    elsif ($credentials->{token}) {
       $headers{Authorization} = "token $credentials->{token}";
    }

    # This can't be done at object creation because we autodetect the
    # need for 2FA when GitHub says we need it, so we won't know to
    # prompt at object creation time.
    if ($self->prompt_2fa) {
        my $otp = $self->zilla->chrome->prompt_str(
            "GitHub two-factor authentication code for '$credentials->{login}'",
            { noecho => 1 },
        );

        $headers{'X-GitHub-OTP'} = $otp;
        $self->log([ "Using two-factor authentication" ]);
    }

    return \%headers;
}

lib/Dist/Zilla/Plugin/GitHub/Create.pm  view on Meta::CPAN

);

has has_downloads => (
    is      => 'ro',
    isa     => 'Bool',
    default => 1
);

#pod =head1 SYNOPSIS
#pod
#pod Configure git with your GitHub credentials:
#pod
#pod     $ git config --global github.user LoginName
#pod     $ git config --global github.password GitHubPassword
#pod
#pod Alternatively you can install L<Config::Identity> and write your credentials
#pod in the (optionally GPG-encrypted) C<~/.github> file as follows:
#pod
#pod     login LoginName
#pod     password GitHubpassword
#pod
#pod (if only the login name is set, the password will be asked interactively)
#pod
#pod then, in your F<profile.ini>:
#pod
#pod     # default config

lib/Dist/Zilla/Plugin/GitHub/Create.pm  view on Meta::CPAN

=head1 NAME

Dist::Zilla::Plugin::GitHub::Create - Create a new GitHub repo on dzil new

=head1 VERSION

version 0.49

=head1 SYNOPSIS

Configure git with your GitHub credentials:

    $ git config --global github.user LoginName
    $ git config --global github.password GitHubPassword

Alternatively you can install L<Config::Identity> and write your credentials
in the (optionally GPG-encrypted) C<~/.github> file as follows:

    login LoginName
    password GitHubpassword

(if only the login name is set, the password will be asked interactively)

then, in your F<profile.ini>:

    # default config

lib/Dist/Zilla/Plugin/GitHub/Update.pm  view on Meta::CPAN

);

has meta_home => (
    is      => 'ro',
    isa     => 'Bool',
    default => 0
);

#pod =head1 SYNOPSIS
#pod
#pod Configure git with your GitHub credentials:
#pod
#pod     $ git config --global github.user LoginName
#pod     $ git config --global github.password GitHubPassword
#pod
#pod Alternatively you can install L<Config::Identity> and write your credentials
#pod in the (optionally GPG-encrypted) C<~/.github> file as follows:
#pod
#pod     login LoginName
#pod     password GitHubpassword
#pod
#pod (if only the login name is set, the password will be asked interactively).
#pod
#pod You can also generate an access token for "full control over repositories" by following
#pod L<these instructions|https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/>,
#pod

lib/Dist/Zilla/Plugin/GitHub/Update.pm  view on Meta::CPAN

    };

    return $config;
};

sub after_release {
    my $self      = shift;
    my ($opts)    = @_;
    my $dist_name = $self->zilla->name;

    return if (!$self->_has_credentials);

    my $repo_name = $self->_get_repo_name($self->_credentials->{login});
    if (not $repo_name) {
        $self->log('cannot update GitHub repository info');
        return;
    }

    my $params = {
        name => ($repo_name =~ /\/(.*)$/)[0],
        description => $self->zilla->abstract,
    };

lib/Dist/Zilla/Plugin/GitHub/Update.pm  view on Meta::CPAN

=head1 NAME

Dist::Zilla::Plugin::GitHub::Update - Update a GitHub repo's info on release

=head1 VERSION

version 0.49

=head1 SYNOPSIS

Configure git with your GitHub credentials:

    $ git config --global github.user LoginName
    $ git config --global github.password GitHubPassword

Alternatively you can install L<Config::Identity> and write your credentials
in the (optionally GPG-encrypted) C<~/.github> file as follows:

    login LoginName
    password GitHubpassword

(if only the login name is set, the password will be asked interactively).

You can also generate an access token for "full control over repositories" by following
L<these instructions|https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/>,

lib/Dist/Zilla/PluginBundle/GitHub.pm  view on Meta::CPAN

    isa     => 'Bool',
    lazy    => 1,
    default => sub {
            defined $_[0]->payload->{meta_home} ?
                $_[0]->payload->{meta_home} : 0
        }
);

#pod =head1 SYNOPSIS
#pod
#pod Configure git with your GitHub credentials:
#pod
#pod     $ git config --global github.user LoginName
#pod     $ git config --global github.password GitHubPassword
#pod
#pod Alternatively you can install L<Config::Identity> and write your credentials
#pod in the (optionally GPG-encrypted) C<~/.github> file as follows:
#pod
#pod     login LoginName
#pod     password GitHubpassword
#pod
#pod (if only the login name is set, the password will be asked interactively)
#pod
#pod then, in your F<dist.ini>:
#pod
#pod     [@GitHub]

lib/Dist/Zilla/PluginBundle/GitHub.pm  view on Meta::CPAN

=head1 NAME

Dist::Zilla::PluginBundle::GitHub - GitHub plugins all-in-one

=head1 VERSION

version 0.49

=head1 SYNOPSIS

Configure git with your GitHub credentials:

    $ git config --global github.user LoginName
    $ git config --global github.password GitHubPassword

Alternatively you can install L<Config::Identity> and write your credentials
in the (optionally GPG-encrypted) C<~/.github> file as follows:

    login LoginName
    password GitHubpassword

(if only the login name is set, the password will be asked interactively)

then, in your F<dist.ini>:

    [@GitHub]

t/01-update.t  view on Meta::CPAN

use Path::Tiny;
use Test::DZil;
use Test::Fatal;
use Test::Deep;
use Test::Deep::JSON;

{
    use Dist::Zilla::Plugin::GitHub;
    package Dist::Zilla::Plugin::GitHub;
    no warnings 'redefine';
    sub _build_credentials { return {login => 'bob', pass => q{} } }
    sub _get_repo_name { 'bob/My-Stuff' }
}

my $http_request;
{
    use HTTP::Tiny;
    package HTTP::Tiny;
    no warnings 'redefine';
    sub request {
        my $self = shift;



( run in 0.260 second using v1.01-cache-2.11-cpan-4d50c553e7e )