Dist-Zilla-Plugin-Bitbucket
view release on metacpan or search on metacpan
* Dist::Zilla::Plugin::Bitbucket::Update
Update Bitbucket repo info on release
* Dist::Zilla::Plugin::Bitbucket::Meta
Add Bitbucket repo info to META.{yml,json}
Configuration
Configure git with your Bitbucket credentials:
$ git config --global bitbucket.user LoginName
$ git config --global bitbucket.password MySecretPassword
Alternatively you can install Config::Identity and write your
credentials in the (optionally GPG-encrypted) ~/.bitbucket file as
follows:
login LoginName
password MySecretPassword
(if only the login name is set, the password will be asked
interactively)
ATTRIBUTES
lib/Dist/Zilla/Plugin/Bitbucket.pm view on Meta::CPAN
if ( -d '.git' ) {
return 'git';
} elsif ( -d '.hg' ) {
return 'hg';
} else {
die "Unknown local repository type!";
}
},
);
sub _get_credentials {
my ($self, $nopass) = @_;
# TODO I'm so lazy...
## no critic (InputOutput::ProhibitBacktickOperators)
my %identity = Config::Identity::Bitbucket->load;
my ($login, $pass);
if (%identity) {
$login = $identity{'login'};
lib/Dist/Zilla/Plugin/Bitbucket.pm view on Meta::CPAN
if ($url =~ /bitbucket\.org.*?[:\/](.*)\.git$/) {
$repo = $1;
} else {
$repo = $self->zilla->name;
}
}
# Make sure we return full path including user
if ($repo !~ /.*\/.*/) {
($login, undef) = $self->_get_credentials(1);
$repo = "$login/$repo";
}
} else {
# Get it from .hgrc
if ( -f '.hg/hgrc' ) {
require File::Slurp::Tiny;
my $hgrc = File::Slurp::Tiny::read_file( '.hg/hgrc' );
# TODO this regex sucks.
# apoc@box:~/test-hg$ cat .hg/hgrc
lib/Dist/Zilla/Plugin/Bitbucket.pm view on Meta::CPAN
=item *
L<Dist::Zilla::Plugin::Bitbucket::Meta>
Add Bitbucket repo info to META.{yml,json}
=back
=head2 Configuration
Configure git with your Bitbucket credentials:
$ git config --global bitbucket.user LoginName
$ git config --global bitbucket.password MySecretPassword
Alternatively you can install L<Config::Identity> and write your credentials
in the (optionally GPG-encrypted) C<~/.bitbucket> file as follows:
login LoginName
password MySecretPassword
(if only the login name is set, the password will be asked interactively)
=head1 ATTRIBUTES
=head2 remote
lib/Dist/Zilla/Plugin/Bitbucket/Create.pm view on Meta::CPAN
{
# we are in a completely different path and as such the auto-detection logic won't work!
my $p = pushd( $root );
$p = $p; # shutup UsedVars warning
$params->{'scm'} = $self->scm;
}
# construct the HTTP request!
my $http = HTTP::Tiny->new;
my ($login, $pass) = $self->_get_credentials(0);
$headers->{'authorization'} = "Basic " . MIME::Base64::encode_base64("$login:$pass", '');
$headers->{'content-type'} = "application/json";
# We use the v2.0 API to create
my $url = 'https://api.bitbucket.org/2.0/repositories/' . $login . '/' . $repo_name; # TODO encode the repo_name and login?
$self->log([ "Creating new Bitbucket repository '%s'", $repo_name ]);
my $response = $http->request( 'POST', $url, {
content => encode_json( $params ),
headers => $headers
});
lib/Dist/Zilla/Plugin/Bitbucket/Meta.pm view on Meta::CPAN
my $self = shift;
my $repo_name = $self->_get_repo_name;
return {} if (!$repo_name);
if($repo_name =~ /\/(.*)$/) {
$repo_name = $1;
} else {
die "unknown repo name";
}
my ($login, undef) = $self->_get_credentials(1);
return if (!$login);
# Build the meta structure
my $html_url = 'https://bitbucket.org/' . $login . '/' . $repo_name;
my $meta = {
'resources' => {
'repository' => {
'web' => $html_url,
'url' => ( $self->scm eq 'git' ? 'git://git@bitbucket.org:' . $login . '/' . $repo_name . '.git' : $html_url ),
'type' => $self->scm,
lib/Dist/Zilla/Plugin/Bitbucket/Update.pm view on Meta::CPAN
use HTTP::Tiny 0.050;
use MIME::Base64 3.14;
use JSON::MaybeXS 1.002006 qw( encode_json decode_json );
extends 'Dist::Zilla::Plugin::Bitbucket';
with 'Dist::Zilla::Role::AfterRelease';
sub after_release {
my $self = shift;
my ($login, $pass) = $self->_get_credentials(0);
return if (!$login);
my $repo_name = $self->_get_repo_name(1);
# set the repo settings
my ($params, $headers);
$params->{'description'} = $self->zilla->abstract;
$params->{'website'} = $self->zilla->distmeta->{'resources'}{'homepage'};
# construct the HTTP request!
( run in 0.248 second using v1.01-cache-2.11-cpan-4d50c553e7e )