| 1 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | package Dist::Zilla::Plugin::GitHub::CreateRelease; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | our $VERSION = '0.0012'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # ABSTRACT: Create a GitHub Release | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Pithub::Repos::Releases; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Config::Identity; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Git::Wrapper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use URI::Escape qw( uri_unescape ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use File::Slurper qw/read_text read_binary/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use CPAN::Changes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | with 'Dist::Zilla::Role::AfterRelease'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 4 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 4 | has hash_alg => (is => 'ro', default => 'sha256'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 4 | has repo => (is => 'ro'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 4 | has repo_owner => (is => 'ro'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | has branch => (is => 'ro', default => 'main'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | has remote_name => (is => 'ro', default => 'origin'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | has title_template => (is => 'ro', default => 'Version RELEASE - TRIAL CPAN release'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | has notes_as_code => (is => 'ro', default => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 4 | has github_notes => (is => 'ro', default => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | has notes_from => (is => 'ro', default => 'SignReleaseNotes'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | has notes_file => (is => 'ro', default => 'Release-VERSION'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | has draft => (is => 'ro', default => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | has add_checksum => (is => 'ro', default => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 4 | has org_id => (is => 'ro', default => 'github'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub _create_release { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_release: not called CC=16 SCAR=56.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $tag = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my $branch = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my $title = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $notes = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $filename = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $cpan_tar = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | my @fields = ("login", "token"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my %identity = Config::Identity->load_check($self->{org_id}, \@fields); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | my $org = $self->{org_id} ? $self->{org_id} : "github"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | die "Unable to load github token from ~/.$org-identity or ~/.$org" if (! defined $identity{token}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | my $releases = Pithub::Repos::Releases->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | user => $self->{repo_owner} || $self->_get_repo_owner() || $identity{login} || $self->{username}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | repo => $self->{repo} || $self->_get_repo_name(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | token => $identity{token}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/12
$self->{'repo_owner'} || $self->_get_repo_owner || $identity{'login'} || $self->{'username'}
$self->{"repo_owner"} or $self->_get_repo_owner or $identity{"login"}
$self->{"repo_owner"} or $self->_get_repo_owner
$self->{'repo'} || $self->_get_repo_name
MC/DC0%0/4
$self->{'repo_owner'} || $self->_get_repo_owner || $identity{'login'} || $self->{'username'}
$self->{"repo_owner"}
$self->_get_repo_owner
$identity{"login"}
$self->{'username'}
MC/DC0%0/2
$self->{'repo'} || $self->_get_repo_name
$self->{'repo'}
$self->_get_repo_name
Truth table0%0/5
A or B or C || D
A= $self->{"repo_owner"}B= $self->_get_repo_ownerC= $identity{"login"}D= $self->{'username'}
Truth table0%0/3
A || B
A= $self->{'repo'}B= $self->_get_repo_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | die "Unable to instantiate Pithub::Repos::Releases" if (! defined $releases); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | my $release = $releases->create( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | data => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | tag_name => "$tag", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | target_commitish => $branch, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | name => $title, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | body => $notes, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | draft => $self->{draft} ? \1 : \0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | prerelease => $self->zilla->is_trial ? \1 : \0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | generate_release_notes => $self->{github_notes} ? \1 : \0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # ->response is the underlying HTTP::Response object, not a status code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # string, so comparing it with `eq '404'`/`eq '422'` never matches and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # these two checks never fired; every failure fell through to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # generic "Unable to create GitHub release" below. ->code (as already | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # used for the 403 check two lines down) delegates to the response's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # numeric status and is what these comparisons need. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | die "Discussion category name is invalid" if ($release->code eq '404'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | die "Validation failed, or the endpoint has been spammed." if ($release->code eq '422'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | die "login ($identity{login}) or token invalid for the specified repository ($releases->{repo})\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | if ($release->code eq '403'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if (! defined $release->content->{id}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | die "Unable to create GitHub release\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $self->log("Release created at $releases->{repo} for $identity{login}"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | my $asset = $releases->assets->create( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | release_id => $release->content->{id}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | name => $filename, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | data => $cpan_tar, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | content_type => 'application/gzip', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if ($asset->code eq '201') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $self->log("CPAN archive appended to GitHub release: $tag"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $self->log("Unable to append CPAN archive GitHub release: $tag"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | sub _menu { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_menu: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my @items = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | print "Enter the number of the git remote where you want to create a release:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | print "Valid values are:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | print "\n?: "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | foreach my $item( @items ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $item =~ m/remote\.(.*)\.url/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | printf "%d: %s\n", ++$count, $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | print "\n?: "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | while( my $line = <STDIN> ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | chomp $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | if ( $line =~ m/\d+/ && $line <= @items ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$line =~ /\d+/ and $line <= @items
MC/DC0%0/2
$line =~ /\d+/ and $line <= @items
$line =~ /\d+/
$line <= @items
Truth table0%0/3
A and B
A= $line =~ /\d+/B= $line <= @items
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | return $line - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | print "\n?: "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | sub _get_repo_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_repo_name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $setting = "remote." . $self->{remote_name} . ".url"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $self->log("Release will be created using $setting\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $git = Git::Wrapper->new('./'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my @url; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | @url = $git->RUN('config', '--get', $setting); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $self->log("Unable to find git \'$setting\' using git config --get $setting\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my @settings; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | @settings = $git->RUN('config', '--name-only', '--get-regexp', 'remote\..*\.url'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $self->log("You do not seem to have any remote repositories defined'\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $self->log("Run \'git config --name-only --get-regexp remote\..*\.url\' to review\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | return ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $number = $self->_menu(@settings); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | @url = $git->RUN('config', '--get', $settings[$number]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $self->log("Unable to find git \'$settings[$number]\' using git config --get $settings[$number]\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $self->log("You do not seem to have a remote repository set at: \'$settings[$number]\'\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | return ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | my $basename = $self->_repo_name_from_url($url[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $self->log("Release will be created using $basename"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | return $basename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 6 | ▶ | sub _repo_name_from_url { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_repo_name_from_url: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 6 | my $url = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 6 | my $basename = uri_unescape( basename( URI->new($url)->path ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # Strip only a trailing ".git" suffix. The old s/.git// matched any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # character followed by "git" anywhere in the string, so a repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # whose name contains "git" (e.g. p5-git-libgit2) lost the wrong part | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # and turned into p5-libgit2. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 6 | $basename =~ s/\.git$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 6 | return $basename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # The remote url's path holds both the owner and the repo name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # (e.g. "pplu/kubernetes-rest.git"), but _repo_name_from_url only ever | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # kept the last segment. That silently discarded the owner, so a release | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # was always attempted under the github-identity login instead of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # repository's actual owner -- which fails whenever they differ, e.g. for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # a repo that isn't owned by the account named in ~/.github-identity. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | sub _get_repo_owner { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_repo_owner: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my $setting = "remote." . $self->{remote_name} . ".url"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my $git = Git::Wrapper->new('./'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | my @url; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | @url = $git->RUN('config', '--get', $setting); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | return $self->_repo_owner_from_url($url[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 6 | ▶ | sub _repo_owner_from_url { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_repo_owner_from_url: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 6 | my $url = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 6 | my $path = URI->new($url)->path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 6 | $path =~ s{^/+}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 6 | my @parts = split m{/}, $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 6 | pop @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 6 | ▶ | return unless @parts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 5 | return uri_unescape( join('/', @parts) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | sub _generate_release_notes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_release_notes: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my $filename = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my $notes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | return "" if (! $self->{add_checksum}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $notes = $self->_get_checksum($filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | return $self->_as_code($notes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | sub _get_notes_from_changes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_notes_from_changes: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | my $filename = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my $git = Git::Wrapper->new('./'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my @tags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | @tags = $git->RUN('for-each-ref', 'refs/tags/*', '--sort=-taggerdate', '--count=2', '--format=%(refname:short)'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $self->log("Unable to get the last two tags from git"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | #FIXME this is pretty much a failure but we will at least return something | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | return $self->{add_checksum} ? $self->_as_code($self->_get_checksum($filename)) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | $self->_as_code($filename); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | my $vers = $tags[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my $prev = $tags[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $changes = CPAN::Changes->load($self->{notes_file}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my $notes = $changes->find_release($tags[0])->serialize(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | return $self->_as_code($notes) if (! $self->{add_checksum}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $notes .= $self->_get_checksum($filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | return $self->_as_code($notes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 3 | ▶ | sub _extract_changes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract_changes: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 3 | my ($self, $text, $vers, $prev) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 3 | my $print = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 3 | my $notes = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 3 | for my $line (split /\n/, $text) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # On the first release "git for-each-ref --count=2" returns a single | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # tag, so $prev is undef; guard against it to avoid an uninitialized | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | # warning. \Q...\E keeps version numbers (e.g. 0.003) from being | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | # treated as regex patterns. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 20 | ▶ | $print = 1 if (defined $vers && $line =~ /^\Q$vers\E/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $vers and $line =~ /^\Q$vers\E/
MC/DC50%1/2
defined $vers and $line =~ /^\Q$vers\E/
defined $vers
$line =~ /^\Q$vers\E/
Truth table66%2/3
A and B
A= defined $versB= $line =~ /^\Q$vers\E/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 20 | ▶ | $print = 0 if (defined $prev && $line =~ /^\Q$prev\E/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $prev and $line =~ /^\Q$prev\E/
MC/DC100%2/2
defined $prev and $line =~ /^\Q$prev\E/
defined $prev
$line =~ /^\Q$prev\E/
Truth table100%3/3
A and B
A= defined $prevB= $line =~ /^\Q$prev\E/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 20 | ▶ | $notes .= $line . "\n" if $print; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 3 | return $notes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | sub _get_notes_from_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_notes_from_file: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my $filename = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | my $version = $self->_get_version(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $notes_file = $self->{notes_file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $notes_file =~ s/VERSION/$version/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $notes = read_text($notes_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | return $self->_as_code($notes) if (! $self->{add_checksum}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | return $self->_as_code($notes) if ($self->{notes_from} eq 'SignReleaseNotes'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | $notes .= $self->_get_checksum($filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | return $self->_as_code($notes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | sub after_release { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_release: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | my $filename = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | my $tag = _get_git_tag(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $branch = $self->{branch}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my $title = $self->{title_template}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | $title =~ s/RELEASE/$tag/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | $title =~ s/TRIAL/Official/ if (!$self->zilla->is_trial); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my $notes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | if ($self->{notes_from} eq 'SignReleaseNotes' or $self->{notes_from} eq 'FromFile') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$self->{"notes_from"} eq "SignReleaseNotes" or $self->{"notes_from"} eq "FromFile"
MC/DC0%0/2
$self->{"notes_from"} eq "SignReleaseNotes" or $self->{"notes_from"} eq "FromFile"
$self->{"notes_from"} eq "SignReleaseNotes"
$self->{"notes_from"} eq "FromFile"
Truth table0%0/3
A or B
A= $self->{"notes_from"} eq "SignReleaseNotes"B= $self->{"notes_from"} eq "FromFile"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $notes = $self->_get_notes_from_file($filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } elsif ($self->{notes_from} eq 'ChangeLog') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $notes = $self->_get_notes_from_changes($filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } elsif ($self->{notes_from} eq 'GitHub::CreateRelease') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $notes = $self->_generate_release_notes($filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | my $cpan_tar = read_binary($filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my($basename, $dirs, $suffix) = fileparse($filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | $self->_create_release($tag, $branch, $title, $notes, $basename, $cpan_tar); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | sub _as_code { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_as_code: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my $text = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | return '```' . "\n" . $text . "\n" . '```' if $self->{notes_as_code}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | sub _get_git_tag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_git_tag: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | my $git = Git::Wrapper->new('./'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my @tags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | @tags = $git->RUN('for-each-ref', 'refs/tags/*', '--sort=-taggerdate', '--count=1', '--format=%(refname:short)'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | $self->log("Unable to get the current release's tag from git"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | #FIXME this is pretty much a failure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | return $tags[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | sub _get_checksum { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_checksum: not called CC=3 SCAR=21.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my $filename = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 4 | ▶ | use Digest::SHA; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | my $sha = Digest::SHA->new($self->{hash_alg}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my $digest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | if ( -e $filename ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | open my $fh, '<:raw', $filename or die "$filename: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $sha->addfile($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $digest = $sha->hexdigest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | my $checksum = uc($self->{hash_alg}) . " hash of CPAN release\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | $checksum .= "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | $checksum .= "$digest *$filename\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | $checksum .= "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | return $checksum; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | sub _get_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_version: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | return $self->{zilla}->version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | sub _get_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | my ($self, $filename) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | $filename =~ s/-+\d+.*$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | $filename =~ s/-/::/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | return $filename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | sub BUILDARGS { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | my $args = @_ == 1 ? shift : {@_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | if (not exists $args->{notes_file}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | $args->{notes_file} = 'Changes' if ($args->{notes_from} eq 'ChangeLog'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | $args->{notes_file} = 'Release-VERSION' if ($args->{notes_from} eq 'SignReleaseNotes'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 4 | ▶ | no Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||