1#line 1 2package Module::Install::GithubMeta; 3 4use strict; 5use warnings; 6use Cwd; 7use base qw(Module::Install::Base); 8use vars qw($VERSION); 9 10$VERSION = '0.12'; 11 12sub githubmeta { 13 my $self = shift; 14 return unless $Module::Install::AUTHOR; 15 return unless _under_git(); 16 return unless $self->can_run('git'); 17 return unless my ($git_url) = `git remote show -n origin` =~ /URL: (.*)$/m; 18 return unless $git_url =~ /github\.com/; # Not a Github repository 19 my $http_url = $git_url; 20 $git_url =~ s![\w\-]+\@([^:]+):!git://$1/!; 21 $http_url =~ s![\w\-]+\@([^:]+):!http://$1/!; 22 $http_url =~ s!\.git$!/tree!; 23 $self->repository( 24 { 25 type => 'git', 26 url => $git_url, 27 web => $http_url, 28 }, 29 ); 30 $self->homepage( $http_url ) unless $self->homepage(); 31 return 1; 32} 33 34sub _under_git { 35 return 1 if -e '.git'; 36 my $cwd = getcwd; 37 my $last = $cwd; 38 my $found = 0; 39 while (1) { 40 chdir '..' or last; 41 my $current = getcwd; 42 last if $last eq $current; 43 $last = $current; 44 if ( -e '.git' ) { 45 $found = 1; 46 last; 47 } 48 } 49 chdir $cwd; 50 return $found; 51} 52 53'Github'; 54__END__ 55 56#line 114 57