App-git-ship
view release on metacpan or search on metacpan
lib/App/git/ship.pm view on Meta::CPAN
my $self = shift;
my $file = $ENV{GIT_SHIP_CONFIG} || '.ship.conf';
my $config = {};
return $config unless open my $CFG, '<:encoding(UTF-8)', $file;
while (<$CFG>) {
chomp;
warn "[ship::config] $_\n" if DEBUG == 2;
m/\A\s*(?:\#|$)/ and next; # comments
s/\s+(?<!\\)\#\s.*$//; # remove inline comments
m/^\s*([^\=\s][^\=]*?)\s*=\s*(.*)$/ or next;
my ($k, $v) = ($1, $2);
$v =~ s!\s+$!!g;
next unless length $v;
$config->{$k} = $v;
$config->{$k} =~ s!\\\#!#!g;
warn "[ship::config] $1 = $2\n" if DEBUG;
}
return $config;
}
sub _build_config_param_author {
my $self = shift;
my $format = shift || '%an <%ae>';
open my $GIT, '-|', qw(git log), "--format=$format"
or $self->abort("git log --format=$format: $!");
my $author = decode 'UTF-8', readline $GIT;
$self->abort("Could not find any author in git log") unless $author;
chomp $author;
warn "[ship::author] $format = $author\n" if DEBUG;
return $author;
}
sub _build_config_param_bugtracker {
return $ENV{GIT_SHIP_BUGTRACKER}
|| join('/', shift->config('homepage'), 'issues') =~ s!(\w)//!$1/!r;
}
sub _build_config_param_homepage {
return $ENV{GIT_SHIP_HOMEPAGE} || shift->config('repository') =~ s!\.git$!!r;
}
sub _build_config_param_license { $ENV{GIT_SHIP_LICENSE} || 'artistic_2' }
sub _build_config_param_project_name { $ENV{GIT_SHIP_PROJECT_NAME} || 'unknown' }
sub _build_config_param_repository {
my $self = shift;
my $repository;
open my $REPOSITORIES, '-|', qw(git remote -v) or $self->abort("git remote -v: $!");
while (<$REPOSITORIES>) {
next unless /^origin\s+(\S+).*push/;
$repository = $1;
last;
}
$repository ||= lc sprintf 'https://github.com/%s/%s',
$self->config('username') || $ENV{GITHUB_USERNAME} || scalar(getpwuid $<),
$self->config('project_name') =~ s!::!-!gr;
$repository =~ s!^[^:]+:!https://github.com/! unless $repository =~ /^http/;
warn "[ship::repository] $repository\n" if DEBUG;
return $repository;
}
sub _get_template {
my ($self, $name) = @_;
my $class = ref $self;
my $str;
no strict 'refs';
for my $package ($class, @{"$class\::ISA"}) {
$str = Mojo::Loader::data_section($package, $name) or next;
$name = "$package/$name";
last;
}
return $str ? Mojo::Template->new->name($name)->vars(1)->parse($str) : undef;
}
1;
=encoding utf8
=head1 NAME
App::git::ship - Git command for shipping your project
=head1 VERSION
0.37
=head1 SYNOPSIS
See L<App::git::ship::perl/SYNOPSIS> for how to build Perl projects.
Below is a list of useful git aliases:
# git build
$ git config --global alias.build 'ship build'
# git cl
$ git config --global alias.cl 'ship clean'
# git start
# git start My/Project.pm
$ git config --global alias.start 'ship start'
=head1 DESCRIPTION
L<App::git::ship> is a L<git|http://git-scm.com/> command for building and
shipping your project.
The main focus is to automate away the boring steps, but at the same time not
get in your (or any random contributor's) way. Problems should be solved with
sane defaults according to standard rules instead of enforcing more rules.
L<App::git::ship> differs from other tools like L<dzil|Dist::Zilla> by I<NOT>
( run in 1.733 second using v1.01-cache-2.11-cpan-39bf76dae61 )