[libdist-zilla-plugin-githubmeta-perl] 03/11: allow checking multiple remotes; use smart urls
Axel Beckert
abe at deuxchevaux.org
Sun Apr 26 22:25:38 UTC 2015
This is an automated email from the git hooks/post-receive script.
abe pushed a commit to annotated tag 0.12
in repository libdist-zilla-plugin-githubmeta-perl.
commit b66a1c9b8416815ccce7ea14b5cfdffac0b2f16c
Author: Ricardo Signes <rjbs at cpan.org>
Date: Mon May 2 17:46:58 2011 -0400
allow checking multiple remotes; use smart urls
---
lib/Dist/Zilla/Plugin/GithubMeta.pm | 48 +++++++++++++++++++++++++++----------
1 file changed, 36 insertions(+), 12 deletions(-)
diff --git a/lib/Dist/Zilla/Plugin/GithubMeta.pm b/lib/Dist/Zilla/Plugin/GithubMeta.pm
index 8b26b66..5e628ff 100644
--- a/lib/Dist/Zilla/Plugin/GithubMeta.pm
+++ b/lib/Dist/Zilla/Plugin/GithubMeta.pm
@@ -19,24 +19,48 @@ has 'homepage' => (
coerce => 1,
);
-has remote => (
- is => 'ro',
- default => 'origin',
+has 'remote' => (
+ is => 'ro',
+ isa => 'ArrayRef[Str]',
+ default => sub { [ 'origin' ] },
);
sub metadata {
my $self = shift;
return unless _under_git();
return unless can_run('git');
- my $origin = $self->remote;
- return unless my ($git_url) = `git remote show -n $origin` =~ /URL: (.*)$/m;
- return unless $git_url =~ /github\.com/; # Not a Github repository
- my $web_url = $git_url;
- $git_url =~ s![\w\-]+\@([^:]+):!git://$1/!;
- $web_url =~ s![\w\-]+\@([^:]+):!http://$1/!;
- $web_url =~ s!\.git$!/tree!;
- my $home_url = $self->homepage ? $self->homepage->as_string : $web_url;
- return { resources => { repository => { url => $git_url, type => 'git', web => $web_url }, homepage => $home_url } };
+
+ my $git_url;
+ for my $remote (@{ $self->remote }) {
+ next unless $git_url = $self->_url_for_remote($remote);
+ last if $git_url =~ /github\.com/; # Not a Github repository
+ undef $git_url;
+ }
+
+ return unless $git_url;
+
+ $git_url =~ s![\w\-]+\@([^:]+):!http://$1/!;
+ $git_url =~ s!\.git$!!;
+
+ my $home_url = $self->homepage ? $self->homepage->as_string : $git_url;
+
+ return {
+ resources => {
+ homepage => $home_url,
+ repository => {
+ type => 'git',
+ url => $git_url,
+ web => $git_url,
+ },
+ }
+ };
+}
+
+sub _url_for_remote {
+ my ($self, $remote) = @_;
+ my ($url) = `git remote show -n $remote` =~ /URL: (.*)$/m;
+
+ return $url;
}
sub _under_git {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libdist-zilla-plugin-githubmeta-perl.git
More information about the Pkg-perl-cvs-commits
mailing list