| 1 | # vim: ts=4:sw=4:et:ai:sts=4 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # KGB - an IRC bot helping collaboration | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Copyright © 2009,2013 Damyan Ivanov | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # Copyright © 2018 Colin Finck <colin@reactos.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # This program is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # the terms of the GNU General Public License as published by the Free Software | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # Foundation; either version 2 of the License, or (at your option) any later | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # version. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # This program is distributed in the hope that it will be useful, but WITHOUT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # details. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # You should have received a copy of the GNU General Public License along with | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # this program; if not, write to the Free Software Foundation, Inc., 51 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | package App::KGB::Client::Git; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 8 | our $VERSION = 1.28; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 8 | ▶ | use base 'App::KGB::Client'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 8 | ▶ | use Git; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 8 | ▶ | use Carp qw(confess); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 8 | __PACKAGE__->mk_accessors( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | qw( changesets old_rev new_rev refname git_dir _git _commits reflog | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | squash_threshold squash_msg_template | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | branch_ff_msg_template | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | enable_branch_ff_notification | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | tag_squash_threshold tag_squash_msg_template | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 8 | ▶ | use App::KGB::Change; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 8 | ▶ | use App::KGB::Commit; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 8 | ▶ | use App::KGB::Commit::Tag; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 8 | ▶ | use Encode qw(decode_utf8 encode_utf8 FB_CROAK LEAVE_SRC); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 8 | ▶ | use IPC::Run; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | App::KGB::Client::Git - Git support for KGB client | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | my $c = App::KGB::Client::Git->new({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | git_dir => '/some/where', # defaults to $ENV{GIT_DIR} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | old_rev => 'a7c42f58', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | new_rev => '8b37ed8a', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | App::KGB::Client::Git provides KGB client with knowledge about Git | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | repositories. Its L<|describe_commit> method returns a series of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | L<App::KGB::Commit> objects, each corresponding to the next commit of the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | received series. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | =head1 CONSTRUCTION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | =head2 App::KGB::Client::Git->new( { parameters... } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | Input data can be given in any of the following ways: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | =item as parameters to the constructor | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # a single commit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | my $c = App::KGB::Client::Git->new({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | old_rev => '9ae45bc', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | new_rev => 'a04d3ef', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | refname => 'master', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | =item as a list of revisions/refnames | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # several commits | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | my $c = App::KGB::Client::Git->new({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | changesets => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | [ '4b3d756', '62a7c8f', 'master' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | [ '7a2fedc', '0d68c3a', 'my' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | All the other ways to supply the changes data is converted internally to this | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | one. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | =item in a file whose name is in the B<reflog> parameter | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | A file name of C<-> means standard input, which is the normal way for Git | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | post-receive hooks to get the data. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | The file must contain three words separated by spaces on each line. The first | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | one is taken to be the old revision, the second is the new revision and the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | third is the refname. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | =item on the command line | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | Useful when testing the KGB client from the command line. If neither | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | B<old_rev>, B<new_rev>, B<refname> nor B<changesets> is given to the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | constructor, and if @ARGV has exactly three elements, they are taken to be old | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | revision, new revision and refname respectively. Only one commit can be | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | represented on the command line. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | In all of the above methods, the location of the F<.git> directory can be given | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | in the B<git_dir> parameter, or it will be taken from the environment variable | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | B<GIT_DIR>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | =head2 B<git-config> parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | The following parameters can be set in the C<[kgb]> section of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | L<git-config(1)>. If present, they override the settings in the configuration | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | file and these given on the command line. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | =item project-id | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | The project ID. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | See L<App::KGB::Client/project-id> for details. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | =item web-link | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | See L<App::KGB::Client/web-link> for details. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | =item squash-threshold I<number> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | Unique to Git KGB client. Sets a threshold of the notifications produced for a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | given branch update. If there are more commits in the update, instead of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | producing huge amounts of notifications, the commits are "squashed" into one | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | notification per branch with a summary of the changes. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | The default value is C<20>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | =item squash-message-template I<string> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | A template for construction of squashed messages. See | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | L<App::KGB::Client/message-template> for details. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | The default is C<${{module} }${{branch} }${{commit} }${{author-name} }${{log}}>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | =item tag-squash-threshold I<number> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | Unique to Git KGB client. Sets a threshold of the notifications produced | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | for tag creations. If there are more tags created in the push, instead | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | of producing huge amounts of notifications, the tags are "squashed" into | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | one notification summarizing the information. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | The default value is C<5>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | =item tag-squash-message-template I<string> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | A template for construction of squashed tags messages. See | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | L<App::KGB::Client/message-template> for details. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | The default is C<${{module} }${{author-name} }${{log}}>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | =item enable-branch-ff-notification I<bool> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | Enables notifications about branch updates whose commits have already been | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | reported. Normally this causes a notification like C<fast forward> to appear. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | If you don't like this, set it to false. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | The default is C<true>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=23 SCAR=63.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my $self = $class->SUPER::new(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | $self->git_dir( $ENV{GIT_DIR} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | unless defined( $self->git_dir ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | defined( $self->git_dir ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | or confess | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | "'git_dir' is mandatory; either supply it or define GIT_DIR in the environment"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $self->_git( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | Git->repository( Repository => encode_utf8( $self->git_dir ) ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | unless ( $self->module ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | require Cwd; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my @dirs = File::Spec->splitdir( Cwd::abs_path( $self->git_dir ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | pop @dirs if @dirs and $dirs[-1] eq '.git'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@dirs and $dirs[-1] eq ".git"
MC/DC0%0/2
@dirs and $dirs[-1] eq ".git"
@dirs
$dirs[-1] eq ".git"
Truth table0%0/3
A and B
A= @dirsB= $dirs[-1] eq ".git"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my $module = $dirs[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | $module =~ s/\.git$// if $module; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | $module = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | eval { decode_utf8( $module, FB_CROAK | LEAVE_SRC ) } // $module; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
eval {
do {
&decode_utf8($module, 9)
}
} // $module
MC/DC0%0/2
eval {
do {
&decode_utf8($module, 9)
}
} // $module
eval {
do {
&decode_utf8($module, 9)
}
}
$module
Truth table0%0/3
A // B
A= eval {
do {
&decode_utf8($module, 9)
}
}B= $module
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $self->module($module); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | if ( my $pid = $self->_git->config('kgb.project-id') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $self->repo_id($pid); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | if ( my $wl = $self->_git->config('kgb.web-link') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $self->web_link($wl); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | if ( my $st = $self->_git->config('kgb.squash-threshold') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $self->squash_threshold($st); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | $self->squash_threshold(20) unless defined $self->squash_threshold; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | if ( my $tst = $self->_git->config('kgb.tag-squash-threshold') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $self->tag_squash_threshold($tst); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | $self->tag_squash_threshold(5) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | unless defined $self->tag_squash_threshold; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if ( my $smt = $self->_git->config('kgb.squash-message-template') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $self->squash_msg_template($smt); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | $self->squash_msg_template('${{module} }${{branch} }${{commit} }${{author-name} }${{log}}') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | unless $self->squash_msg_template; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | if ( my $tsmt = $self->_git->config('kgb.tag-squash-message-template') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $self->tag_squash_msg_template($tsmt); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | $self->tag_squash_msg_template( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | '${{module} }${{author-name}}${ {log}}' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | ) unless $self->tag_squash_msg_template; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | $self->branch_ff_msg_template('${{module} }${{branch} }${{commit} }${{author-name}} fast-forward') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | unless $self->branch_ff_msg_template; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $ebfn = $self->_git->config('kgb.enable-branch-ff-notification'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | if ( defined($ebfn) and $ebfn ne '' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $ebfn and $ebfn ne ""
MC/DC0%0/2
defined $ebfn and $ebfn ne ""
defined $ebfn
$ebfn ne ""
Truth table0%0/3
A and B
A= defined $ebfnB= $ebfn ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | $ebfn = ( $ebfn eq 'false' ) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $self->enable_branch_ff_notification($ebfn); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | $self->enable_branch_ff_notification(1) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | unless defined $self->enable_branch_ff_notification; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | sub _parse_reflog { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_reflog: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # read changeset data from a file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $self->changesets( [] ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | open( $fh, $self->reflog // '-' ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/4
$self->reflog // "-"
'open(' . $self->reflog // '-' . "): $!"
MC/DC0%0/1
$self->reflog // "-"
$self->reflog
MC/DC0%0/1
'open(' . $self->reflog // '-' . "): $!"
'open(' . $self->reflog
Truth table0%0/2
A
A= $self->reflog
Truth table0%0/2
A
A= 'open(' . $self->reflog
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | or die "open(" . $self->reflog // '-' . "): $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # in order for '-' to open STDIN, we must use two-argument form of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # open(). see 'perldoc -f open' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my @cs = split( /\s+/, $_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | @cs == 3 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | or confess | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | "Invalid data on row $.. Must contain three space-separated words"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | push @{ $self->changesets }, \@cs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | die "Reflog was empty. Broken git post-receive hook?\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | unless @{ $self->{changesets} }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | =item describe_commit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | Returns an instance of L<App::KGB::Change> class for each commit. Returns | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | B<undef> when all commits were processed. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | sub describe_commit { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_commit: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | $self->_detect_commits unless defined( $self->_commits ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | return shift @{ $self->_commits }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | sub _reset { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reset: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | $self->_commits(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $self->changesets(undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | sub _detect_commits { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_detect_commits: not called CC=23 SCAR=63.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if ( defined( $self->old_rev // $self->new_rev // $self->refname ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/6
($self->old_rev // $self->new_rev) // $self->refname
$self->old_rev // $self->new_rev
MC/DC0%0/3
($self->old_rev // $self->new_rev) // $self->refname
$self->old_rev
$self->new_rev
$self->refname
Truth table0%0/4
A // B // C
A= $self->old_revB= $self->new_revC= $self->refname
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # single commit | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | defined( $self->old_rev ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $self->old_rev and defined $self->new_rev and defined $self->refname
defined $self->old_rev and defined $self->new_rev
MC/DC0%0/3
defined $self->old_rev and defined $self->new_rev and defined $self->refname
defined $self->old_rev
defined $self->new_rev
defined $self->refname
Truth table0%0/4
A and B and C
A= defined $self->old_revB= defined $self->new_revC= defined $self->refname
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | and defined( $self->new_rev ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | and defined( $self->refname ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | or confess | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | "either all of old_rev, new_rev and refname shall be present or neither"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | defined $self->changesets | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | and confess | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | "You can't supply both old_rev, new_rev and ref_name and changesets"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | defined $self->reflog | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | and confess | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | "You can't supply both old_rev, new_rev and ref_name and reflog"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | $self->changesets( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | [ [ $self->old_rev, $self->new_rev, $self->refname ] ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | elsif ( defined( $self->changesets ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # ready changesets | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | ref( $self->changesets ) and ref( $self->changesets ) eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $self->changesets and ref $self->changesets eq "ARRAY"
MC/DC0%0/2
ref $self->changesets and ref $self->changesets eq "ARRAY"
ref $self->changesets
ref $self->changesets eq "ARRAY"
Truth table0%0/3
A and B
A= ref $self->changesetsB= ref $self->changesets eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | or confess "'changesets' must be an arrayref"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | for( @{ $self->changesets } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | defined($_) and ref($_) and ref($_) eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $_ and ref $_ and ref $_ eq "ARRAY"
defined $_ and ref $_
MC/DC0%0/3
defined $_ and ref $_ and ref $_ eq "ARRAY"
defined $_
ref $_
ref $_ eq "ARRAY"
Truth table0%0/4
A and B and C
A= defined $_B= ref $_C= ref $_ eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | or confess "Each changeset must be an arrayref"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | @$_ == 3 or confess "Each changeset must contain three elements"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | defined $self->reflog | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | and confess "You can't supply both changesets and reflog"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | elsif ( @ARGV == 3 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | # a single changeset on the command line | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $self->changesets( [ [@ARGV] ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | $self->_parse_reflog; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $self->_commits([]); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | $self->_describe_branch_updates; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | for my $next ( @{ $self->changesets } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my ( $old_rev, $new_rev, $refname ) = @$next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $self->_process_changeset_simple( $old_rev, $new_rev, $refname ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my @tags; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | for ( @{ $self->_commits } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | push @tags, $_ if eval { $_->isa('App::KGB::Commit::Tag') }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | if ( scalar(@tags) > $self->tag_squash_threshold ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | # remove tags from the commit stream | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | @{ $self->_commits } = grep { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | not eval { $_->isa('App::KGB::Commit::Tag') } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | } @{ $self->_commits }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | $self->init_painter; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # add a synthetic tag summary | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | push @{ $self->_commits }, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | $self->format_message( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | $self->tag_squash_msg_template, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | log => sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 'Pushed %s, %s, %d other tags and %s', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | $self->colorize( branch => $tags[0]->tag_name ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | $self->colorize( branch => $tags[1]->tag_name ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | scalar(@tags) - 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | $self->colorize( branch => $tags[-1]->tag_name ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | author_login => $ENV{USER}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | author_name => $self->_get_full_user_name, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | sub _exists { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exists: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my ( $self, $obj ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # we resort to running 'git cat-file' ourselves as the Git wrapper doesn't | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | # provide an easy way to do so without polluting STDERR in case the object | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | # doesn't exist | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | # Sad but true | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | my ( $in, $out, $err ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | # this will exit with status 128 if the object does not exist | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | IPC::Run::run [ 'git', "--git-dir=" . $self->git_dir, 'cat-file', '-e', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | $obj ], \$in, \$out, \$err; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | # success means the object exists | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | if ( $? == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | #warn "$obj exists"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | my $res = $? >> 8; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | # exit code of 128 means the object doesn't exist | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | if ( $res == 128 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | #warn "$obj doesn't exist"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | return 0 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | die | |||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | "Command 'git cat-file -e $obj' exited with code $res and said '$err'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | sub _describe_ref { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_describe_ref: not called CC=17 SCAR=57.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | my( $self, $new ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | # raw commit looks like this: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | #commit cc746cf3f6b8937c059cf6311a8903dba9936749 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | #tree 76bcae9bdbcfab304c8265d2c2cc245048c9f0f3 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | #parent 7e99c8b051169e43189c822c8db77bcad5956734 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | #author Damyan Ivanov <dmn@debian.org> 1257538837 +0200 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | #committer Damyan Ivanov <dmn@debian.org> 1257538837 +0200 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | # update README.debian with regard to repackaging | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | #:100644 100644 603d70d... b81e344... M debian/README.debian | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | #:100644 100644 f1511af... 573335e... M debian/changelog | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my ( $fh, $ctx ) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | = $self->_git->command_output_pipe( 'show', '--pretty=raw', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | '--no-abbrev', '--raw', $new ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my @log; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | my @changes; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | my @parents; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my $author_login; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | my $author_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | my $author_via; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | if ( /^author (.+) <([^>]+)@[^>]+>/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | utf8::decode( $author_name = $1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | utf8::decode( $author_login = $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | if ( /^committer (.+) <([^>]+)@[^>]+>/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | my $committer_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | utf8::decode( $committer_name = $1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | if ($committer_name ne $author_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | $author_via = $author_name . ' (via ' . $committer_name . ')'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | $author_via = $author_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | push( @parents, substr( $1, 0, 7 ) ), next if /^parent\s+(\S+)/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | push( @log, $1 ), next if /^ (.*)/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | if (s/^::?//) { # a merge commit | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | my @old_modes; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | while ( s/^(\d{6,6})\s+// ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | push @old_modes, $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | my $new_mode = pop @old_modes; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | my @old_shas; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | while (s/^([0-9a-f]{40,40})\s+//) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | push @old_shas, $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | my $new_sha = pop @old_shas; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | my $flag = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | s/^(\S+)\s+// and $flag = $1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | my $file = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | # maybe deleted? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | if ( $new_sha =~ /^0+$/ or $flag =~ /D/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$new_sha =~ /^0+$/ or $flag =~ /D/
MC/DC0%0/2
$new_sha =~ /^0+$/ or $flag =~ /D/
$new_sha =~ /^0+$/
$flag =~ /D/
Truth table0%0/3
A or B
A= $new_sha =~ /^0+$/B= $flag =~ /D/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | push @changes, App::KGB::Change->new("(D)$file"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | # maybe created? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | elsif ( not @parents or grep {/^0+$/} @old_shas or $flag =~ /A/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
not @parents or grep {/^0+$/;} @old_shas or $flag =~ /A/
not @parents or grep {/^0+$/;} @old_shas
MC/DC0%0/3
not @parents or grep {/^0+$/;} @old_shas or $flag =~ /A/
not @parents
grep {/^0+$/;} @old_shas
$flag =~ /A/
Truth table0%0/4
not(A) or B or C
A= not @parentsB= grep {/^0+$/;} @old_shasC= $flag =~ /A/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | push @changes, App::KGB::Change->new("(A)$file"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | my $mode_change | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | = ( grep { $_ ne $new_mode } @old_modes ) ? '+' : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | push @changes, App::KGB::Change->new("(M$mode_change)$file"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | $self->_git->command_close_pipe( $fh, $ctx ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | id => substr( $new, 0, 7 ), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | author => $author_login, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | author_name => $author_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | author_via => $author_via, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | log => join( "\n", @log ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | changes => \@changes, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | parents => \@parents, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | sub _describe_annotated_tag { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_describe_annotated_tag: not called CC=14 SCAR=53.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | my( $self, $ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | my ( $fh, $ctx ) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | = $self->_git->command_output_pipe( 'show', '--stat', '--format=raw', $ref ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my @log; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | my $author_login; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my $author_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | my $tag; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | my $signed; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | my $commit; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | # annotated tags are listed as | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | # tag <tag name> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | # Tagger: Some One <sone@swhere.nev> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | # Tag message | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | # commit <ref> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | # Author: ..... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | # .... <tag description> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | my $in_header = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | $commit = substr( $1, 0, 7 ), last if /^commit (.+)/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | if (/^-----BEGIN PGP SIGNATURE/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | $signed = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | defined($_ = <$fh>) or last; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } until (/^-----END PGP SIGNATURE/); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | if ($in_header) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | $tag = $1, next if /^tag (.+)/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | if ( /^Tagger: (.+) <([^>@]+)@[^>]+>/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | utf8::decode( $author_name = $1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | utf8::decode( $author_login = $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | $in_header = 0 if /^$/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | push( @log, $_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | $self->_git->command_close_pipe( $fh, $ctx ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | ▶ | pop @log if $log[$#log] eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | if ($commit) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | push @log, "tagged commit: $commit"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | if ( scalar(@log) == 2 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | # spare an extra line | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | $log[0] .= " ($log[1])"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | $#log = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | return App::KGB::Commit::Tag->new( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | { id => substr( $ref, 0, 7 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | author => $author_login, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | author_name => $author_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | log => join( "\n", @log ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | branch => $signed ? 'signed tags' : 'tags', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | changes => [ App::KGB::Change->new("(A)$tag") ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | tag_name => $tag, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | =item format_git_stat I<text> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | returns a colored version of I<text>, which is expected to be the result | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | of C<git diff --shortstat>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | ▶ | sub format_git_stat { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_git_stat: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | my ( $self, $text ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | my $result = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | $self->init_painter; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | while ( length($text) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | warn "$text" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | ▶ | if ( $text =~ s/\s*(.*?)(\d+ files? changed)// ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | $result .= $1 . $self->colorize( modification => $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | if ( $text =~ s/\s*(.*?)(\d+) insertions?\(\++\)// ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | $result .= $1 . $self->colorize( addition => "$2(+)" ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | if ( $text =~ s/\s*(.*?)(\d+) deletions?\(-+\)// ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | $result .= $1 . $self->colorize( deletion => "$2(-)" ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | # nothing matched | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | $result .= $text; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | ▶ | sub _describe_branch_updates { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_describe_branch_updates: not called CC=44 SCAR=75.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | my %ref_branch; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | my %ref_parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | my @new_branches; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | my %new_branches; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | my @updated_branches; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | my %branch_updates; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my %branch_head; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | my %updated_heads; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | my @old_revs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | # keys are sha1s, values are hashrefs with keys branch names | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | my %branch_tips; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | warn "# ======== processing changesets" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my @params = qw(--topo-order --parents --first-parent); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | my @updated; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | my %branch_has_commits; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | for my $cs ( @{ $self->changesets } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | my ( $old, $new, $ref ) = @$cs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | warn "# considering $old $new $ref" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | next unless $ref =~ m{^refs/heads/(.+)}; # not interested in tags | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | my $branch = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | next if $new =~ /^0+$/; # nor dropped branches | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | $ref_branch{$new} = $branch; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | warn "# $new is on $branch" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | warn "$branch head is $new" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | $branch_head{$branch} = $new; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | $branch_tips{$new}{$branch} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | $updated_heads{$branch} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | ▶ | if ( $old =~ /^0+$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | push @new_branches, $branch; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | $new_branches{$branch} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | push @updated, "$new", "^$old"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | push @old_revs, $old; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | push @updated_branches, $branch; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | $branch_updates{$branch} = [ $old => $new ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | my @existing_branches; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | my @old_branches; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | my @lines | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | = $self->_git->command( 'branch', '-v', '--no-abbrev' ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | for my $l (@lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | $l =~ s/^[ *]+//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | my ( $ref, $sha, $ignore ) = split( ' ', $l ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | $branch_head{$ref} = $sha; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | $branch_tips{$sha}{$ref} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | $ref_branch{$sha} //= $ref; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ref_branch{$sha} //= $ref
MC/DC0%0/2
$ref_branch{$sha} //= $ref
$ref_branch{$sha}
$ref
Truth table0%0/3
A //= B
A= $ref_branch{$sha}B= $ref
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | push @existing_branches, $ref unless $new_branches{$ref}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | push @old_branches, $ref | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | unless $new_branches{$ref} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | or $branch_updates{$ref}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$new_branches{$ref} or $branch_updates{$ref}
MC/DC0%0/2
$new_branches{$ref} or $branch_updates{$ref}
$new_branches{$ref}
$branch_updates{$ref}
Truth table0%0/3
A or B
A= $new_branches{$ref}B= $branch_updates{$ref}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | warn "existing branches: @existing_branches" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | warn "old branches: @old_branches" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | my @commits; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | my %reported; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | ▶ | if (@updated) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | push @params, map( "^$_", @old_branches ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | warn "# git rev-list @params @updated" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | my @lines = $self->_git->command( 'rev-list', @params, @updated); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | do { warn $_ for @lines } if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | ▶ | if ( $self->squash_threshold | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->squash_threshold and scalar @lines > $self->squash_threshold
MC/DC0%0/2
$self->squash_threshold and scalar @lines > $self->squash_threshold
$self->squash_threshold
scalar @lines > $self->squash_threshold
Truth table0%0/3
A and B
A= $self->squash_thresholdB= scalar @lines > $self->squash_threshold
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | and scalar(@lines) > $self->squash_threshold ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | for my $branch (@updated_branches) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | my ($old,$new) = @{ $branch_updates{$branch} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | my $stat = $self->_git->command( 'diff', '--shortstat', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | "$old..$new" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | my @commit_lines | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | = $self->_git->command( 'rev-list', '--topo-order', $new, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | "^$old" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | push @commits, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | $self->format_message( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | $self->squash_msg_template, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | branch => $branch, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | commit_id => substr( $new, 0, 7 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | author_login => $ENV{USER}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | author_name => $self->_get_full_user_name, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | log => sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | '%d commits pushed, %s', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | scalar(@commit_lines), $self->format_git_stat($stat), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | warn "# $commits[-1]" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | $branch_has_commits{$branch} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | my @refs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | for (@lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | my ( $ref, @parents ) = split(/\s+/); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | push @refs, $ref; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | ▶ | if ( @parents and not $ref_branch{ $parents[0] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@parents and not $ref_branch{$parents[0]}
MC/DC0%0/2
@parents and not $ref_branch{$parents[0]}
@parents
not $ref_branch{$parents[0]}
Truth table0%0/3
A and not(B)
A= @parentsB= not $ref_branch{$parents[0]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | $ref_branch{ $parents[0] } = $ref_branch{$ref} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | or confess | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | "Ref $ref with parent $parents[0] is of unknown branch"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | warn | |||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | "# $parents[0] determined to be on branch $ref_branch{$ref}" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | if 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | warn "# revisions to describe: " . join( ' ', @refs ) if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | for my $ref (@refs) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | if ( $reported{$ref} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | warn "$ref already reported" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | my $cmt = App::KGB::Commit->new( $self->_describe_ref($ref) ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | warn "# putting $ref on $ref_branch{$ref}" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | $cmt->branch( $ref_branch{$ref} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | unshift @commits, $cmt; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | $reported{$ref} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | $branch_has_commits{ $ref_branch{$ref} } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | # see if some updated branch was without any reported commits | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | # if this case put a fast-forward notification | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | ▶ | if ( $self->enable_branch_ff_notification ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | for ( @updated_branches ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | ▶ | next if $branch_has_commits{$_}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | push @commits, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | App::KGB::Commit->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | { branch => $_, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | id => substr( $branch_updates{$_}[1], 0, 7 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | author => $ENV{USER}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | author_name => $self->_get_full_user_name, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | log => 'fast forward', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | # walk the branch until it is exhausted or a revision with multiple | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | # children (branch point) is reached | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | # when walking skip all commits already reported | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | # terminate walk on old revs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | ▶ | if ( @new_branches ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | # exclude commits in all branches that aren't part of this push | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | my @exclude; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | for ( @existing_branches ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | ▶ | push @exclude, $branch_head{$_} unless $updated_heads{$_}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | push @exclude, @old_revs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | $_ = "^$_" for @exclude; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | for my $b (@new_branches) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | warn "# Looking into new branch $b" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | warn "# git rev-list --topo-order --first-parent --parents $b @exclude" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | my @lines = $self->_git->command( 'rev-list', '--topo-order', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | '--first-parent', '--parents', $b, @exclude ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | my @br_commits; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | my $branch_point; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | my $last_rev; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | for my $line (@lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | warn "# $line" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | my ( $rev, $parent, @other_parents ) = split( /\s+/, $line ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | $last_rev = $rev; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | ▶ | if ( $reported{$rev} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | warn "$rev is already reported" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | my $pipe = $self->_git->command_output_pipe( 'rev-list', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | '--children', $rev ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | my $in = <$pipe>; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | $self->_git->command_close_pipe($pipe); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | my @children; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | ▶ | if ($in) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | chomp($in); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | warn "# Children of $rev: @children" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | @children = split(/\s+/, $in); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | shift @children; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | # a branch point is: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | # * a commit with more than one child | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | # * a tip of another branch | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | ▶ | if (@children > 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
@children > 1 or exists $branch_tips{$rev} and not exists $branch_tips{$rev}{$b}
exists $branch_tips{$rev} and not exists $branch_tips{$rev}{$b}
MC/DC0%0/3
@children > 1 or exists $branch_tips{$rev} and not exists $branch_tips{$rev}{$b}
@children > 1
exists $branch_tips{$rev}
not exists $branch_tips{$rev}{$b}
Truth table0%0/4
A or B and not(C)
A= @children > 1B= exists $branch_tips{$rev}C= not exists $branch_tips{$rev}{$b}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | or ( exists $branch_tips{$rev} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | and not exists $branch_tips{$rev}{$b} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | unshift @br_commits, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | App::KGB::Commit->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | { log => "Branch '$b' created", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | id => substr( $rev, 0, 7 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | branch => $b, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | $branch_point = $rev; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | warn "$b branched at $rev" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | ▶ | if ($parent) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | ▶ | $ref_branch{$parent} //= $ref_branch{$rev}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ref_branch{$parent} //= $ref_branch{$rev}
MC/DC0%0/2
$ref_branch{$parent} //= $ref_branch{$rev}
$ref_branch{$parent}
$ref_branch{$rev}
Truth table0%0/3
A //= B
A= $ref_branch{$parent}B= $ref_branch{$rev}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | $ref_parent{$rev} = $parent; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | my $cmt = App::KGB::Commit->new( $self->_describe_ref($rev) ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | warn "# putting $rev on $ref_branch{$rev}" if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | $cmt->branch( $ref_branch{$rev} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | unshift @br_commits, $cmt; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | $reported{$rev} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | ▶ | if ( not $branch_point and $last_rev and $ref_parent{$last_rev} ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $branch_point and $last_rev and $ref_parent{$last_rev}
not $branch_point and $last_rev
MC/DC0%0/3
not $branch_point and $last_rev and $ref_parent{$last_rev}
not $branch_point
$last_rev
$ref_parent{$last_rev}
Truth table0%0/4
not(A) and B and C
A= not $branch_pointB= $last_revC= $ref_parent{$last_rev}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | $branch_point = $ref_parent{$last_rev}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | warn "$b branched at $branch_point" if 0 and $branch_point; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | ▶ | if ( $self->squash_threshold | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->squash_threshold and scalar @br_commits > $self->squash_threshold
MC/DC0%0/2
$self->squash_threshold and scalar @br_commits > $self->squash_threshold
$self->squash_threshold
scalar @br_commits > $self->squash_threshold
Truth table0%0/3
A and B
A= $self->squash_thresholdB= scalar @br_commits > $self->squash_threshold
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | and scalar(@br_commits) > $self->squash_threshold ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | my $log = sprintf( 'New branch with %d commits pushed', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | scalar(@br_commits) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | ▶ | if ($branch_point) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | $log .= ', ' | |||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | . $self->format_git_stat( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | $self->_git->command( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 'diff', '--shortstat', "$branch_point..$b" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | $log .= " since "; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | $log .= "$ref_branch{$branch_point}/" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | ▶ | if $ref_branch{$branch_point}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | $log .= substr( $branch_point, 0, 7 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | push @commits, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | $self->format_message( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | $self->squash_msg_template, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | branch => $b, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | author_login => $ENV{USER}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | author_name => $self->_get_full_user_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | log => $log, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | commit_id => substr( $branch_head{$b}, 0, 7 ), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | push @commits, @br_commits; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | push @commits, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | App::KGB::Commit->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | ▶ | { id => substr( $branch_head{$b}, 0, 7 ), | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | log => "branch created", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | branch => $b, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | changes => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | ) unless @br_commits; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | warn '# ' . scalar(@commits) . ' commits queued' if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | push @{ $self->_commits }, @commits; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | sub _process_changeset_simple { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_changeset_simple: not called CC=20 SCAR=60.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | my ( $self, $old_rev, $new_rev, $refname ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | $_ = $self->_git->command_oneline( 'rev-parse', $_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | for ( $old_rev, $new_rev ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | # see what kind of commit is this | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | my $ref_update_type; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | ▶ | if ( $old_rev =~ /^0+$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | # 0000000 -> 1234567 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | $ref_update_type = 'create'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | elsif ( $new_rev =~ /^0+$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | # 7654321 -> 0000000 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | $ref_update_type = 'delete'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | # 2345678 -> 3456789 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | $ref_update_type = 'update'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | my ( $rev, $rev_type ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | ▶ | if ( $ref_update_type eq 'delete' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | $rev = $old_rev; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | $rev_type = $self->_git->command_oneline( 'cat-file', '-t', $old_rev ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | else { # create or update | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | $rev = $new_rev; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | $rev_type = $self->_git->command_oneline( 'cat-file', '-t', $new_rev ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | my ( $refname_type, $short_refname, $branch, $tag, $remote ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | # revision type and location tell us if this is | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | # - working branch | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | # - tracking branch | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | # - unannoted tag | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | # - annotated tag | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | ▶ | if ( $refname =~ m{refs/tags/.+} and $rev_type eq 'commit' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/3
$refname =~ m[refs/tags/.+] and $rev_type eq "commit"
MC/DC0%0/2
$refname =~ m[refs/tags/.+] and $rev_type eq "commit"
$refname =~ m[refs/tags/.+]
$rev_type eq "commit"
Truth table0%0/3
A and B
A= $refname =~ m[refs/tags/.+]B= $rev_type eq "commit"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | # un-annotated tag | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | $refname_type = "tag"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | ( $tag = $refname ) =~ s,refs/tags/,,; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | ▶ | elsif ( $refname =~ m{refs/tags/.+} and $rev_type eq 'tag' ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$refname =~ m[refs/tags/.+] and $rev_type eq "tag"
MC/DC0%0/2
$refname =~ m[refs/tags/.+] and $rev_type eq "tag"
$refname =~ m[refs/tags/.+]
$rev_type eq "tag"
Truth table0%0/3
A and B
A= $refname =~ m[refs/tags/.+]B= $rev_type eq "tag"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | # annotated tag | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | $refname_type = "annotated tag"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | ( $tag = $refname ) =~ s,refs/tags/,,; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | ▶ | elsif ( $refname =~ m{refs/heads/.+} and $rev_type eq 'commit' ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$refname =~ m[refs/heads/.+] and $rev_type eq "commit"
MC/DC0%0/2
$refname =~ m[refs/heads/.+] and $rev_type eq "commit"
$refname =~ m[refs/heads/.+]
$rev_type eq "commit"
Truth table0%0/3
A and B
A= $refname =~ m[refs/heads/.+]B= $rev_type eq "commit"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | # branch | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | $refname_type = "branch"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | ( $branch = $refname ) =~ s,refs/heads/,,; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | ▶ | elsif ( $refname =~ m{refs/remotes/.+} and $rev_type eq 'commit' ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$refname =~ m[refs/remotes/.+] and $rev_type eq "commit"
MC/DC0%0/2
$refname =~ m[refs/remotes/.+] and $rev_type eq "commit"
$refname =~ m[refs/remotes/.+]
$rev_type eq "commit"
Truth table0%0/3
A and B
A= $refname =~ m[refs/remotes/.+]B= $rev_type eq "commit"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | # tracking branch | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | $refname_type = "tracking branch"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | ( $remote = $refname ) =~ s,refs/remotes/,,; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | warn <<"EOF"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | *** Push-update of tracking branch, $refname | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | *** no notification sent. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | # Anything else (is there anything else?) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | warn "*** Unknown type of update to $refname ($rev_type) ignored"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | ▶ | if ( $ref_update_type eq 'create' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 0 | ▶ | if ( $refname_type eq 'tag' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | push @{ $self->_commits }, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | App::KGB::Commit::Tag->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | { id => substr( $new_rev, 0, 7 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | #author => $cmt->author, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | log => "tag '$tag' created", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | branch => 'tags', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | changes => [ App::KGB::Change->new("(A)$tag") ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | tag_name => $tag, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | elsif ( $refname_type eq 'annotated tag' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | push @{ $self->_commits }, $self->_describe_annotated_tag($new_rev); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | # branch creations would be picked by _describe_branch_updates | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | elsif ( $ref_update_type eq 'delete' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | ▶ | push @{ $self->_commits }, App::KGB::Commit->new( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/2
$branch || 'tags'
MC/DC0%0/1
$branch || 'tags'
$branch
Truth table0%0/2
A
A= $branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | { id => substr( $old_rev, 0, 7 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | author => 'TODO: deletor', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | log => ( $branch ? 'branch' : 'tag' ) . ' deleted', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | branch => $branch || 'tags', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | changes => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | App::KGB::Change->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | { action => 'D', path => ( $branch ? '.' : $tag ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | else { # update | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | # should be processed by _describe_branch_updates | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | Copyright (c) 2009, 2013 Damyan Ivanov | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | Based on the shell post-receive hook by Andy Parkins | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | This file is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | the terms of the GNU General Public License as published by the Free Software | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | Foundation; either version 2 of the License, or (at your option) any later | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | version. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | This program is distributed in the hope that it will be useful, but WITHOUT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | details. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | You should have received a copy of the GNU General Public License along with | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | this program; if not, write to the Free Software Foundation, Inc., 51 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||