App-git-ship
view release on metacpan or search on metacpan
lib/App/git/ship/perl.pm view on Meta::CPAN
require CPAN::Uploader;
$uploader = CPAN::Uploader->new(CPAN::Uploader->read_config_file);
unless ($dist_file) {
$self->build;
$self->abort(
"Project built. Run 'git ship' again to post dist to CPAN and remote repostitory.");
}
unless ($self->config('next_version')) {
close ARGV;
local @ARGV = $changelog;
while (<>) {
/^$VERSION_RE\s*/ or next;
$self->config(next_version => $1);
last;
}
}
$self->run_hook('before_ship');
$self->system(qw(git add Makefile.PL), $changelog);
$self->system(qw(git add README.md)) if -e 'README.md';
lib/App/git/ship/perl.pm view on Meta::CPAN
$name[-1] =~ s!\.pm$!!;
return join '::', @name;
}
sub _changes_to_commit_message {
my $self = shift;
my $changelog = $self->config('changelog_filename');
my ($version, @message);
close ARGV; # reset <> iterator
local @ARGV = $changelog;
while (<>) {
last if @message and /^$VERSION_RE\s+/;
push @message, $_ if @message;
push @message, $_ and $version = $1 if /^$VERSION_RE\s+/;
}
$self->abort("Could not find any changes in $changelog") unless @message;
$message[0] =~ s!.*?\n!Released version $version\n\n!s;
local $" = '';
return "@message";
lib/App/git/ship/perl.pm view on Meta::CPAN
my @lines;
$file ||= do { require ExtUtils::Manifest; $ExtUtils::Manifest::DEFAULT_MSKIP; };
unless (-r $file) {
warn "MANIFEST.SKIP included file '$file' not found - skipping\n";
return '';
}
@lines = ("#!start included $file\n");
local @ARGV = ($file);
push @lines, $_ while <>;
return join "", @lines, "#!end included $file\n";
}
sub _make {
my ($self, @args) = @_;
$self->_render_makefile_pl unless -e 'Makefile.PL';
$self->system(perl => 'Makefile.PL') unless -e 'Makefile';
$self->system(make => @args);
lib/App/git/ship/perl.pm view on Meta::CPAN
$release_line = sub {
my $v = shift;
my $str = $self->config('new_version_format');
$str =~ s!(%-?\d*)v!{ sprintf "${1}s", $v }!e;
setlocale LC_TIME, 'C';
$str = strftime $str, localtime;
setlocale LC_TIME, $loc;
return $str;
};
local @ARGV = $changelog;
local $^I = '';
while (<>) {
$self->config(next_version => $1)
if s/^$VERSION_RE\x20*(?:Not Released)?\x20*([\r\n]+)/{ $release_line->($1) . $2 }/e;
print; # print back to same file
}
say '# Building version ', $self->config('next_version') unless $self->SILENT;
$self->abort('Unable to add timestamp to ./%s', $changelog) unless $self->config('next_version');
}
lib/App/git/ship/perl.pm view on Meta::CPAN
'Revision history for perl distribution ' . ($self->config('project_name') =~ s!::!-!gr));
path('Changes')->spurt($changes->serialize);
say "# Generated Changes" unless $self->SILENT;
}
sub _update_version_info {
my $self = shift;
my $version = $self->config('next_version')
or $self->abort('Internal error: Are you sure Changes has a timestamp?');
local @ARGV = ($self->config('main_module_path'));
local $^I = '';
my %r;
while (<>) {
$r{pod} ||= s/$VERSION_RE/$version/ if /^=head1 VERSION/ .. $r{pod} && /^=(cut|head1)/ || eof;
$r{var} ||= s/((?:our)?\s*\$VERSION)\s*=.*/$1 = '$version';/;
print; # print back to same file
}
$self->abort('Could not update VERSION in %s', $self->config('main_module_path')) unless $r{var};
}
t/perl-build.t view on Meta::CPAN
done_testing;
sub create_main_module {
open my $MAIN_MODULE, '>', File::Spec->catfile(qw(lib Perl Build.pm));
print $MAIN_MODULE
"package Perl::Build;\n=head1 NAME\n\nPerl::Build\n\n=head1 VERSION\n\n0.00\n\n=cut\n\nour \$VERSION = '42';\n\n1";
}
sub add_version_to_changes {
my $version = shift;
local @ARGV = ('Changes');
local $^I = '';
while (<>) {
print "$version\n * Some other cool feature for $version.\n\n" if $. == 3;
print;
}
}
sub touch {
open my $FH, '>>', shift;
}
t/perl-ship-changelog-md.t view on Meta::CPAN
ok -e 'Changes', 'Changes was generated by start';
unlink 'Changes';
write_alien_files();
diag 'Build';
$app->config(new_version_format => '## %v (%F)');
eval { $app->ship };
like $@, qr{Project built}, 'Project built';
is $upload_file, '', 'CPAN::Uploader did not upload anything';
local @ARGV = ('CHANGELOG.md');
my $changes = do { local $/; <>; };
like $changes, qr{^\#\#\s0\.04\s\(\w+}s, 'changes was updated with timestamp';
diag 'Ship';
$upload_file = '';
eval { $app->ship };
is $@, '', 'no ship error';
like $upload_file, qr{\bPerl-Changelogmd-0\.04\.tar\.gz$}, 'CPAN::Uploader uploaded version 0.04';
t/perl-ship.t view on Meta::CPAN
$app = App::git::ship->new;
bless $app, $app->detect;
$upload_file = '';
ok !$app->config('next_version'), 'no next_version yet';
eval { $app->ship };
like $@, qr{Unable to add timestamp}, 'Unable to add timestamp';
{
local @ARGV = ('Changes');
local $^I = '';
while (<>) {
print "0.02 Not Released\n - Some other cool feature\n\n" if $. == 3;
print;
}
}
$app->build->ship;
is $app->config('next_version'), '0.02', 'next_version is 0.02';
like $upload_file, qr{\bPerl-Ship-0\.02\.tar\.gz$}, 'CPAN::Uploader uploaded version 0.01';
( run in 0.678 second using v1.01-cache-2.11-cpan-49f99fa48dc )