| 1 | package Minilla::Release::UploadToCPAN; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use ExtUtils::MakeMaker qw(prompt); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Minilla::Util qw(require_optional is_interactive); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Minilla::Logger; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | require_optional('CPAN/Uploader.pm', | |||||||||||||||||||||||||||||||||||||||||
| 12 | 'Release engineering'); | ||||||||||||||||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=17 SCAR=37.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | my ($self, $project, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | my $work_dir = $project->work_dir(); | |||||||||||||||||||||||||||||||||||||||||
| 19 | 5 | my $tar = $work_dir->dist; | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 5 | ▶ | if ($opts->{dry_run} || $ENV{FAKE_RELEASE}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$opts->{"dry_run"} or $ENV{"FAKE_RELEASE"}
MC/DC100%2/2
$opts->{"dry_run"} or $ENV{"FAKE_RELEASE"}
$opts->{"dry_run"}
$ENV{"FAKE_RELEASE"}
Truth table100%3/3
A or B
A= $opts->{"dry_run"}B= $ENV{"FAKE_RELEASE"}
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | infof("Dry run. You don't need the module upload to CPAN\n"); | |||||||||||||||||||||||||||||||||||||||||
| 23 | } elsif ($project->config->{release}->{do_not_upload_to_cpan}) { | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | infof("You disabled CPAN uploading feature in minil.toml.\n"); | |||||||||||||||||||||||||||||||||||||||||
| 25 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | unless (is_interactive()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | errorf("CPAN upload requires confirmation from a terminal. Use a terminal to release, or '--dry-run' to check the release without uploading.\n"); | |||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | infof("Upload to CPAN\n"); | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | my $pause_config = ($opts->{pause_config}) ? $opts->{pause_config} | ||||||||||||||||||||||||||||||||||||||||||
| 32 | : ($project->config->{release}->{pause_config}) ? $project->config->{release}->{pause_config} | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | my $config = CPAN::Uploader->read_config_file($pause_config); | |||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | if (!$config || !$config->{user} || !$config->{password}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$config and $config->{"user"} and $config->{"password"}
$config and $config->{"user"}
MC/DC0%0/3
$config and $config->{"user"} and $config->{"password"}
$config
$config->{"user"}
$config->{"password"}
Truth table25%1/4
A and B and C
A= $configB= $config->{"user"}C= $config->{"password"}
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | die <<EOF | |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | Missing ~/.pause file or your ~/.pause file is wrong. | ||||||||||||||||||||||||||||||||||||||||||
| 39 | You should put ~/.pause file in following format. | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | user {{YOUR_PAUSE_ID}} | ||||||||||||||||||||||||||||||||||||||||||
| 42 | password {{YOUR_PAUSE_PASSWORD}} | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | EOF | ||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | PROMPT: while (1) { | |||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | ▶ | my $answer = prompt("Release to " . ($config->{upload_uri} || 'CPAN') . ' ? [y/n] '); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config->{'upload_uri'} || 'CPAN'
MC/DC0%0/1
$config->{'upload_uri'} || 'CPAN'
$config->{'upload_uri'}
Truth table50%1/2
A
A= $config->{'upload_uri'}
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | ▶ | if ($answer =~ /y/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | last PROMPT; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } elsif ($answer =~ /n/i) { | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | errorf("Giving up!\n"); | |||||||||||||||||||||||||||||||||||||||||
| 54 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | redo PROMPT; | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if ($opts->{trial}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $orig_file = $tar; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $tar =~ s/\.(tar\.gz|tgz|tar.bz2|tbz|zip)$/-TRIAL.$1/ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | or die "Distfile doesn't match supported archive format: $orig_file"; | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | infof("renaming $orig_file -> $tar for TRIAL release\n"); | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | rename $orig_file, $tar or errorf("Renaming $orig_file -> $tar failed: $!\n"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $uploader = CPAN::Uploader->new(+{ | |||||||||||||||||||||||||||||||||||||||||
| 68 | tar => $tar, | ||||||||||||||||||||||||||||||||||||||||||
| 69 | %$config | ||||||||||||||||||||||||||||||||||||||||||
| 70 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $uploader->upload_file($tar); | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | ▶ | unlink($tar) unless Minilla->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||