bin/git-deploy

filter: Statementstmt 27.8% 131 / 471 Branchbran 20.2% 49 / 242 Conditioncond 16.6% 17 / 102 MC/DCmcdc 6.7% 4 / 59 Subroutinesub 61.2% 19 / 31 Podpod n/a totaltotal 24.3% 220 / 905 CC 52 SCAR 37.7
CC
52
Cov
24%
do_interactive_revert
132.0
send_email_with_sendmail
72.0
do_sync_with_sync_hook
72.0
CRAP 43.4
« lib/Git/Deploy.pm ↑ Summary blib/lib/Git/Deploy/Question.pm »
1 #!/usr/bin/perl
2  
3 # ABSTRACT: automate the git steps required for a deploying code from a git repository
4 # PODNAME: git-deploy
5  
6 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 19 ▶use Getopt::Long qw(GetOptions);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 19 ▶use Pod::Usage qw(pod2usage);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 19 ▶use Cwd qw(cwd abs_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 19 ▶use Sys::Hostname qw(hostname);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 19 ▶use POSIX qw(strftime);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 19 ▶use FindBin ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 19 ▶use File::Basename qw(dirname);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 19 ▶use File::Spec::Functions qw(catdir);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 19 our $GIT_DEPLOY_LIB;
18  
19 19 ▶BEGIN {
Subroutine BEGIN: called CC=3 SCAR=11.4
20 19 my $path_to_gd = abs_path($0);
21 19 ▶ if (-l $path_to_gd) {
Branch: 1 branch
BranchTrueFalseTotal
if (-l $path_to_gd) 0 19 19
22 # If we have a symlink in /usr/local/bin we have to resolve it
23 # and then find the library dir.
24 0 $path_to_gd = readlink $path_to_gd;
25 }
26 19 my $git_deploy_dir = dirname($path_to_gd);
27 19 $GIT_DEPLOY_LIB = catdir($git_deploy_dir, '..', 'lib');
28  
29 # we set this up so that it's always in PERL5LIB when hooks execute
30 19 ▶ $ENV{PERL5LIB} .= ":" if $ENV{PERL5LIB};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PERL5LIB"} 19 0 19
31 19 $ENV{PERL5LIB} .= $GIT_DEPLOY_LIB;
32 # and we set this up so that hooks can find it alone
33 19 $ENV{GIT_DEPLOY_LIB}= $GIT_DEPLOY_LIB;
34 }
35 19 ▶use lib $GIT_DEPLOY_LIB;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 19 ▶use Git::Deploy::Timing qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
37 push_timings
38 should_write_timings
39 write_timings
40 19 );
41 12 ▶local $SIG{__DIE__} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
42 12 print STDERR "@_";
43 12 push_timings("gdt_end");
44 12 write_timings();
45 12 die;
46 19 };
47 19 ▶use Git::Deploy::Say;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 19 ▶use Git::Deploy;
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50 # debugging
51 19 ▶use Data::Dumper qw(Dumper);
Subroutine BEGIN: called CC=1 SCAR=0.0
52  
53 # perltidy settings for this file:
54 # perltidy -ple -bbb -bbc -bbs -nolq -l=100 -noll -nola -nwls='=' -isbc -nolc -otr -kis -ci=4
55 #
56  
57 0 ▶sub get_to_mail {
Subroutine get_to_mail: not called CC=4 SCAR=30.0
58 0 my ($action, $to_mail)= @_;
59 0 ▶ $to_mail="" if $to_mail and $to_mail eq 'silent' or $to_mail eq 'none';
Branch: 1 branch
BranchTrueFalseTotal
if $to_mail and $to_mail eq "silent" or $to_mail eq "none" 0 0 0
Condition0%0/6
$to_mail and $to_mail eq "silent" or $to_mail eq "none"
l!l&&r!l&&!r
000
$to_mail and $to_mail eq "silent"
!ll&&!rl&&r
000
MC/DC0%0/3
$to_mail and $to_mail eq "silent" or $to_mail eq "none"
$to_mail $to_mail eq "silent" $to_mail eq "none"
Truth table0%0/5
A and B or C
A= $to_mailB= $to_mail eq "silent"C= $to_mail eq "none"
ABCresult
11X1
0X11
1011
0X00
1000
60 0 return $to_mail;
61 }
62  
63 # Send an E-Mail, early in the file so I can debug subroutines that
64 # use this with BEGIN blocks.
65 0 ▶sub send_email_with_sendmail {
Subroutine send_email_with_sendmail: not called CC=8 SCAR=42.8
66 0 my (%args) = @_;
67  
68 0 ▶ my $to_mail = delete $args{to_mail} || die "Need to_mail =>";
Condition0%0/2
delete $args{'to_mail'} || die('Need to_mail =>')
l!l
00
MC/DC0%0/1
delete $args{'to_mail'} || die('Need to_mail =>')
delete $args{'to_mail'}
Truth table0%0/2
A
A= delete $args{'to_mail'}
Aresult
11
00
69 0 ▶ my $subject = delete $args{subject} || die "Need subject =>";
Condition0%0/2
delete $args{'subject'} || die('Need subject =>')
l!l
00
MC/DC0%0/1
delete $args{'subject'} || die('Need subject =>')
delete $args{'subject'}
Truth table0%0/2
A
A= delete $args{'subject'}
Aresult
11
00
70 0 ▶ my $body = delete $args{body} || die "Need body =>";
Condition0%0/2
delete $args{'body'} || die('Need body =>')
l!l
00
MC/DC0%0/1
delete $args{'body'} || die('Need body =>')
delete $args{'body'}
Truth table0%0/2
A
A= delete $args{'body'}
Aresult
11
00
71  
72 0 my $handle;
73 0 my $sendmail= get_config("mail-tool","/usr/sbin/sendmail -f");
74 0 my $from_name= get_config("user.name");
75 0 my $from_email= get_config("user.email");
76  
77 0 my $cmd= "$sendmail '$from_email' '$to_mail'";
78 0 ▶ if ( $to_mail eq 'debug' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($to_mail eq 'debug') { } 0 0 0
79 0 $handle= \*STDERR;
80 0 print $handle $cmd, "\n";
81 }
82 else {
83 0 ▶ open $handle, "| $cmd"
Branch: 1 branch
BranchTrueFalseTotal
open $handle, "| $cmd" or &_die("Failed to open pipe to ${cmd}: $!\n") 0 0 0
84 or _die "Failed to open pipe to $cmd: $!\n";
85 }
86  
87 0 my $mail= join "", "To: $to_mail\n", "From: $from_name <$from_email>\n", "Subject: $subject\n",
88 "\n$body\n\n\n";
89 0 ▶ _info $mail if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $main::DEBUG 0 0 0
90 0 print $handle $mail;
91 0 ▶ close $handle
Branch: 1 branch
BranchTrueFalseTotal
if $to_mail ne "debug" 0 0 0
92 if $to_mail ne 'debug'; # dont close STDERR accidentally
93  
94 0 return;
95 }
96  
97 # These are higher level functions that wrap the others, and are used directly
98 # from the main code.
99  
100 1 ▶sub do_pre_checks {
Subroutine do_pre_checks: called CC=4 SCAR=23.1
101 1 my ($prefix,$action)= @_;
102  
103 1 push_timings("gdt_internal__do_pre_checks__start");
104  
105 1 ▶ if ( my $unclean_status= check_if_working_dir_is_clean() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $unclean_status = check_if_working_dir_is_clean()) 1 0 1
106 1 _die "working directory not clean. git status reports:\n" . $unclean_status;
107 }
108  
109 # check that we are actually on a branch
110 0 my $branch= get_current_branch();
111 0 ▶ if ( !$branch ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($branch) 0 0 0
112 0 _warn "working directory is not checked out to a branch tip\n",
113 "Checking if this commit is on any branches -- this may take a minute\n";
114 0 my @branches= what_branches_can_reach_head();
115 0 ▶ if ( !@branches ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @branches) { } 0 0 0
116 0 _die "The current commit is not reachable from any branch tip\n",
117 "This probably means someone committed a change against an old commit\n",
118 "You should probably do something like:\n\n",
119 "\tgit checkout -b temporary_branch HEAD\n",
120 "\tgit checkout trunk\n",
121 "\tgit merge temporary_branch\n",
122 "\tgit branch -d temporary_branch\n\n",
123 "However you should investigate what changes were involved before doing so\n";
124 }
125 else {
126 0 _die join( "\n\t", "The current checkout is on the following branches:", @branches ),
127 "\n",
128 "This most likely means that someone has checked out an old commit\n",
129 "and you need to do:\n",
130 "\tgit checkout $branches[0]\n",
131 "and then rerun the original command\n";
132 }
133 }
134 0 push_timings("gdt_internal__do_pre_checks__end");
135 }
136  
137  
138 1 ▶sub do_get_name_list {
Subroutine do_get_name_list: called CC=7 SCAR=36.6
139 1 my ( $ignore_older_than, $list, $list_all, $include_branches )= @_;
140 1 push_timings("gdt_internal__do_get_name_list__start");
141 ###################################################################################
142 # find matching tags
143 1 my $start_time= time;
144 1 my @head_refs= get_sorted_list_of_tags();
145 0 my $elapsed= time - $start_time;
146 0 ▶ _info "get_sorted_list_of_tags() took $elapsed seconds\n" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $main::DEBUG 0 0 0
147 0 ▶ if ($include_branches) {
Branch: 1 branch
BranchTrueFalseTotal
if ($include_branches) 0 0 0
148  
149 # add the branches if requested, but only if @ARGV is empty indicating
150 # that we are not creating a tag (we don't want to return a branch name as a tag).
151 0 push @head_refs, get_branches();
152 }
153 0 $start_time= time;
154 0 ▶ @head_refs= filter_names_by_date( $ignore_older_than, @head_refs )
Branch: 1 branch
BranchTrueFalseTotal
if $ignore_older_than 0 0 0
155 if $ignore_older_than;
156 0 $elapsed= time - $start_time;
157 0 ▶ _info "filter_names_by_date() took $elapsed seconds\n" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $main::DEBUG 0 0 0
158  
159 0 $start_time= time;
160 0 ▶ @head_refs= filter_names_matching_head( $list, @head_refs )
Branch: 1 branch
BranchTrueFalseTotal
unless $list_all 0 0 0
161 if !$list_all;
162 0 $elapsed= time - $start_time;
163 0 ▶ _info "filter_names_matching_head() took $elapsed seconds\n" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $main::DEBUG 0 0 0
164 0 push_timings("gdt_internal__do_get_name_list__end");
165 0 return \@head_refs;
166 }
167  
168 0 ▶sub do_interactive_revert {
Subroutine do_interactive_revert: not called CC=11 SCAR=48.8
169 0 my ( $list_count, $prefix, $action, $ignore_older_than, $include_branches, $deploy_file_name, $message, $rsubject, $rmessage, $revert_choice, $date_fmt )=
170 @_;
171 0 my $tags= do_get_name_list( $ignore_older_than, 1, 1, $include_branches );
172 0 _print colored( ['bold cyan'], "The following commits are available to revert the site to:" ), "\n";
173 0 my @printed= print_refs( {
174 list => 1, #$list,
175 long_digest => 1, #$long_digest,
176 count => $list_count,
177 prefix => $prefix,
178 tag_only => 0, #$tag_only,
179 action => $action,
180 for_interactive => 1,
181 },
182 $tags
183 );
184 0 my $input;
185 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$input or do { do { _print(colored(["bold cyan"], $revert_choice ? "You've selected the choice <$revert_choice> from the above list\n" : 'Please select a commit from 1-' . (0 + @printed) . q[ to revert to, or 'quit' to not do anything: ])); if ($revert_choice) { $input = $revert_choice; } else { chomp($input = readline ARGV); &_log("input: '${input}'"); } ; if (lc $input eq "quit") { $$rsubject = "Aborting revert of $prefix"; $$rmessage = qq[$ENV{"USER"} has instructed git-deploy abort an automated revert of $prefix.\n\n] . "The live tag is still: $printed[0]\n\n"; return "abort"; } ; if ($input =~ /[^0-9]/ or $input < 1 or $input > @printed) { if ($revert_choice) { &_error("Your revert choice of '${input}' is invalid, aborting revert, try again"); return "abort"; } else { undef $input; } ; } } } 0 0 0
186 0 ▶ _print colored( ['bold cyan'],
Branch: 1 branch
BranchTrueFalseTotal
$revert_choice ? : 0 0 0
187 $revert_choice
188 ? "You've selected the choice <$revert_choice> from the above list\n"
189 : "Please select a commit from 1-" . ( 0 + @printed ) . " to revert to, or 'quit' to not do anything: " );
190 0 ▶ if ($revert_choice) {
Branch: 1 branch
BranchTrueFalseTotal
if ($revert_choice) { } 0 0 0
191 0 $input = $revert_choice;
192 } else {
193 0 chomp( $input= <> );
194 0 _log( "input: '$input'");
195 }
196 0 ▶ if ( lc($input) eq 'quit' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $input eq "quit") 0 0 0
197 0 $$rsubject= "Aborting revert of $prefix";
198 0 $$rmessage= "$ENV{USER} has instructed git-deploy abort an automated revert of $prefix.\n\n"
199 . "The live tag is still: $printed[0]\n\n";
200 0 return "abort"; # we dont want to roll out.
201 }
202 0 ▶ if ($input =~ /[^0-9]/ or $input < 1 or $input > @printed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($input =~ /[^0-9]/ or $input < 1 or $input > @printed) 0 0 0
Condition0%0/6
$input =~ /[^0-9]/ or $input < 1 or $input > @printed
l!l&&r!l&&!r
000
$input =~ /[^0-9]/ or $input < 1
l!l&&r!l&&!r
000
MC/DC0%0/3
$input =~ /[^0-9]/ or $input < 1 or $input > @printed
$input =~ /[^0-9]/ $input < 1 $input > @printed
Truth table0%0/4
A or B or C
A= $input =~ /[^0-9]/B= $input < 1C= $input > @printed
ABCresult
1XX1
01X1
0011
0000
203 0 ▶ if ($revert_choice) {
Branch: 1 branch
BranchTrueFalseTotal
if ($revert_choice) { } 0 0 0
204 0 _error "Your revert choice of '$input' is invalid, aborting revert, try again";
205 0 return "abort";
206 } else {
207 0 undef $input;
208 }
209 }
210 } while !$input;
211 0 _tell("Will revert code to tag $printed[$input-1]");
212 0 $$rsubject= "Reverting $prefix from $printed[0] to $printed[$input-1]";
213 0 $$rmessage= "$ENV{USER} has instructed git-deploy to begin an automated revert of $prefix.\n\n"
214 . "The live tag that we are reverting from is: $printed[0]\n\n"
215 . "We will revert to the code previously rolled out as tag $printed[$input-1]\n\n"
216 . "NOTE that a new tag will be generated for the code when it is synchronzied.\n\n";
217  
218 # If we get time someday we should make this happen after the revert is complete, and get the
219 # user to enter in why they did a revert. But for now we wont, as every second during a revert
220 # is precious. -- Yves
221 0 ▶ my $revert_tag= make_dated_tag( $prefix, $date_fmt . "_reverted", $$rsubject, $$rmessage )
Branch: 1 branch
BranchTrueFalseTotal
my $revert_tag = make_dated_tag($prefix, $date_fmt . '_reverted', $$rsubject, $$rmessage) or &_warn("Failed to create revert tag! This shouldn't happen! Ignoring, but this should be fixed!\n") 0 0 0
222 or _warn "Failed to create revert tag! This shouldn't happen! Ignoring, but this should be fixed!\n";
223 0 _tell("Marked $printed[0] as reverted with tag $revert_tag");
224  
225 0 reset_to_name( $action, $printed[ $input - 1 ], $prefix );
226 0 my $sync_hook= get_sync_hook( $prefix );
227 0 ▶ if ($sync_hook) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sync_hook) { } 0 0 0
228 0 return "sync"; # they have a sync hook, so call it.
229 }
230 else {
231 0 return; # no sync hook the procedure is manual
232 }
233 }
234  
235 0 ▶sub do_sync_with_sync_hook {
Subroutine do_sync_with_sync_hook: not called CC=8 SCAR=42.8
236 0 my (%args) = @_;
237  
238 0 ▶ my $env = delete $args{env} || die "Need env =>";
Condition0%0/2
delete $args{'env'} || die('Need env =>')
l!l
00
MC/DC0%0/1
delete $args{'env'} || die('Need env =>')
delete $args{'env'}
Truth table0%0/2
A
A= delete $args{'env'}
Aresult
11
00
239 0 my $actions = delete $args{actions};
240 0 my $push_action_if_ok = delete $args{push_action_if_ok};
241 0 my $disable_further_actions_if_not_ok = delete $args{disable_further_actions_if_not_ok};
242 0 ▶ my $sync_hook = delete $args{sync_hook} || die "Need sync_hook =>";
Condition0%0/2
delete $args{'sync_hook'} || die('Need sync_hook =>')
l!l
00
MC/DC0%0/1
delete $args{'sync_hook'} || die('Need sync_hook =>')
delete $args{'sync_hook'}
Truth table0%0/2
A
A= delete $args{'sync_hook'}
Aresult
11
00
243 0 my $sync_is_abort = delete $args{sync_is_abort};
244  
245 my $ok= eval {
246 0 $ENV{DEPLOY_ROLLOUT_TAG} = $env->{rollout_tag};
247 0 $ENV{DEPLOY_ROLLBACK_TAG} = $env->{start_tag};
248 0 $ENV{DEPLOY_DEPLOY_FILE} = $env->{deploy_file};
249 0 $ENV{DEPLOY_DEPLOY_TEXT} = $env->{deploy_text};
250 0 $ENV{DEPLOY_ROLLOUT_PREFIX} = $env->{rollout_prefix};
251  
252 0 execute_hook($sync_hook);
253 0 ▶ if ($push_action_if_ok and $push_action_if_ok eq "finish") {
Branch: 2 branches
BranchTrueFalseTotal
if ($push_action_if_ok and $push_action_if_ok eq 'finish') { } 0 0 0
elsif ($sync_is_abort) { } 0 0 0
Condition0%0/3
$push_action_if_ok and $push_action_if_ok eq "finish"
!ll&&!rl&&r
000
MC/DC0%0/2
$push_action_if_ok and $push_action_if_ok eq "finish"
$push_action_if_ok $push_action_if_ok eq "finish"
Truth table0%0/3
A and B
A= $push_action_if_okB= $push_action_if_ok eq "finish"
ABresult
0X0
100
111
254 0 _say "Sync ran ok! Everything looks good! Automatically finishing\n";
255 0 push @$actions => $push_action_if_ok;
256 } elsif ($sync_is_abort) {
257 0 _say "Sync back to starting point for rollout abort appeared to run ok\n";
258 }
259  
260 0 1;
261 0 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
my $ok = eval { do { $ENV{"DEPLOY_ROLLOUT_TAG"} = $env->{"rollout_tag"}; $ENV{"DEPLOY_ROLLBACK_TAG"} = $env->{"start_tag"}; $ENV{"DEPLOY_DEPLOY_FILE"} = $env->{"deploy_file"}; $ENV{"DEPLOY_DEPLOY_TEXT"} = $env->{"deploy_text"}; $ENV{"DEPLOY_ROLLOUT_PREFIX"} = $env->{"rollout_prefix"}; execute_hook($sync_hook); if ($push_action_if_ok and $push_action_if_ok eq "finish") { &_say("Sync ran ok! Everything looks good! Automatically finishing\n"); push @$actions, $push_action_if_ok; } elsif ($sync_is_abort) { &_say("Sync back to starting point for rollout abort appeared to run ok\n"); } ; 1 } } or do { my $sync_hook_fail_message = get_config("message-on-sync-hook-fail-whale", "A) Retry the synchronization hook. You can do this by moving to the root of the repository\n and executing the following command by hand:\n\n \$ {SYNC_HOOK}\n\n which if it succeeds can be followed with a\n\n \$ git-deploy finish\n\n If that doesn't work then you should seek further assistance from sysadmin.\n * NOTE * This is NOT an error in git-deploy itself.\n\nB) Inform {SUPPORT_EMAIL} of the failure and any relevant\n output there might be. Please do this even if the manual process works out.\n\n"); _expand_template_variables(\$sync_hook_fail_message, {"SYNC_HOOK", $sync_hook, "SUPPORT_EMAIL", get_config("support-email", "maintainer")}); &_tell("The syncronization hook has returned failure: $@\n\n", " *** DON'T PANIC ***\n\n", "You will now be dropped into 'manual' sync mode. Please follow these instructions:\n\n", $sync_hook_fail_message); if ($disable_further_actions_if_not_ok) { @$actions = (); } } 0 0 0
262  
263 0 my $sync_hook_fail_message = get_config(
264 'message-on-sync-hook-fail-whale',
265 "A) Retry the synchronization hook. You can do this by moving to the root of the repository\n" .
266 " and executing the following command by hand:\n\n" .
267 " \$ {SYNC_HOOK}\n\n" .
268 " which if it succeeds can be followed with a\n\n" .
269 " \$ git-deploy finish\n\n" .
270 " If that doesn't work then you should seek further assistance from sysadmin.\n" .
271 " * NOTE * This is NOT an error in git-deploy itself.\n\n" .
272 "B) Inform {SUPPORT_EMAIL} of the failure and any relevant\n" .
273 " output there might be. Please do this even if the manual process works out.\n\n"
274 );
275 0 _expand_template_variables(
276 \$sync_hook_fail_message,
277 {
278 SYNC_HOOK => $sync_hook,
279 SUPPORT_EMAIL => get_config('support-email','maintainer'),
280 }
281 );
282  
283 0 _tell
284 "The syncronization hook has returned failure: $@\n\n",
285 " *** DON'T PANIC ***\n\n",
286 "You will now be dropped into 'manual' sync mode. Please follow these instructions:\n\n",
287 $sync_hook_fail_message;
288  
289 0 ▶ if ($disable_further_actions_if_not_ok) {
Branch: 1 branch
BranchTrueFalseTotal
if ($disable_further_actions_if_not_ok) 0 0 0
290 # disable any further actions as requested.
291 0 @$actions= ();
292 }
293 };
294  
295 0 return $ok
296 }
297  
298 0 ▶sub show_modified {
Subroutine show_modified: not called CC=7 SCAR=40.3
299 0 my ( $start_tag, $rollout_tag )= @_;
300 0 ▶ if ( !$start_tag ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $start_tag) { } 0 0 0
301 0 return;
302 }
303 else {
304 0 ▶ $rollout_tag ||= "";
Condition0%0/2
$rollout_tag ||= ""
l!l
00
MC/DC0%0/1
$rollout_tag ||= ""
$rollout_tag
Truth table0%0/2
A
A= $rollout_tag
Aresult
11
00
305 }
306 0 my @modified= `git diff --name-status $start_tag..$rollout_tag`;
307 0 my %counts;
308 0 my %type_color= (
309 'M' => { clr => COLOR_MODIFIED, txt => 'Modified' },
310 'A' => { clr => COLOR_ADDED, txt => 'Added' },
311 'D' => { clr => COLOR_DELETED, txt => 'Deleted' },
312 'R' => { clr => COLOR_RENAMED, txt => 'Renamed' },
313 'T' => { clr => COLOR_MODECHG, txt => 'Type (mode) change' },
314 'U' => { clr => COLOR_WARN, txt => 'Unmerged' },
315 'X' => { clr => COLOR_WARN, txt => 'Unknown' },
316 'B' => { clr => COLOR_WARN, txt => 'Pairing broken' },
317 );
318  
319 0 my $total= 0;
320 0 foreach (@modified) {
321 0 chomp;
322 0 my $color;
323 0 my ( $type, $file )= split /\s+/, $_;
324 0 _print colored( [ $type_color{$type}{clr} ], "$type\t$file" ), "\n";
325 0 $counts{$type}++;
326 0 $total++;
327 }
328 0 my $summary= "";
329 0 foreach my $type (qw(M A D R T U X B)) {
330 0 ▶ next unless $counts{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless $counts{$type} 0 0 0
331 $summary .=
332 0 colored( [ $type_color{$type}{clr} ], sprintf "%s: %d", lc $type_color{$type}{txt}, $counts{$type} ) . ", ";
333 }
334 0 $summary =~ s/,\s+\z/\n/;
335 0 ▶ if ($total) {
Branch: 1 branch
BranchTrueFalseTotal
if ($total) { } 0 0 0
336 0 _print "Total files: $total, $summary";
337 }
338 else {
339 0 _print "No files have been modified\n";
340 }
341 0 return;
342 }
343  
344 0 ▶sub _checktag {
Subroutine _checktag: not called CC=3 SCAR=24.8
345 0 my ( $action, $name, $value, $expect_bool )= @_;
346 0 ▶ if ( !$value != !$expect_bool ) {
Branch: 1 branch
BranchTrueFalseTotal
if (!$value != !$expect_bool) 0 0 0
347 0 ▶ my $should= $expect_bool ? "should" : "should not";
Branch: 1 branch
BranchTrueFalseTotal
$expect_bool ? : 0 0 0
348 0 _die "Something is wrong, there $should be a $name tag defined\n" . "when you perform '$action'\n";
349 }
350 }
351  
352 0 ▶sub do_fetch {
Subroutine do_fetch: not called CC=1 SCAR=6.9
353 0 my ($remote_site)= @_;
354 0 fetch_tags( $remote_site );
355 0 fetch( $remote_site, undef );
356 }
357  
358  
359 ###################################################################################
360 # main routine -- read options and do stuff
361 ###################################################################################
362 19 my $list_all= 0;
363 19 my $check_clean= 1;
364 19 my $use_remote= 1;
365  
366 19 my %legal_action= (
367 start => 'start',
368 begin => 'start',
369 sync => 'sync',
370 'manual-sync' => 'manual-sync',
371 finish => 'finish',
372 finnish => 'finnish',
373 end => 'finish',
374 done => 'finish',
375 none => 'none',
376 0 => 'none',
377 '' => 'none',
378 abort => 'abort',
379 oops => 'abort',
380 bail => 'abort',
381 1 => 'start',
382 2 => 'sync',
383 3 => 'finish',
384 4 => 'abort',
385 abort => 'abort',
386 check => 'check',
387  
388 # special
389 good => 'release',
390 release => 'release',
391 show => 'show',
392 tag => 'tag',
393 showtag => 'showtag',
394 'show-tag' => 'showtag',
395 'latest' => 'showtag',
396 hotfix => 'hotfix',
397  
398 # introspection
399 'diff' => 'diff',
400 'log' => 'log',
401 'status' => 'status',
402 'modified' => 'modified',
403  
404 # interactive
405 revert => 'revert',
406 );
407  
408 19 my %git_wrap= (
409 'diff' => 1,
410 'log' => 1,
411 );
412  
413 19 my %custom_options= (
414 'revert' => 1,
415 );
416  
417 19 Getopt::Long::Configure( "require_order", "bundling" );
418 GetOptions(
419 'm|message=s' => \my @message,
420  
421 'prefix=s' => \( my $prefix= '' ),
422 'deploy-file-name=s' => \( my $deploy_file_name ),
423  
424 'to-mail=s' => \( my $to_mail= ($ENV{LIVE_EMAIL_ADDR} || get_config("announce-mail","none"))),
425 'date-fmt=s' => \( my $date_fmt= "%Y%m%d-%H%M%S" ),
426  
427 'check-clean!' => \$check_clean,
428 'remote!' => \$use_remote,
429 'remote-site=s' => \( my $remote_site= 'origin' ),
430 'remote-branch=s' => \( my $remote_branch= '' ),
431  
432 'make-tag' => \( my $make_tag ),
433 'show-tag' => \( my $show_tag ),
434 'tag-only' => \( my $tag_only ),
435 'show-list|list!' => \( my $list ),
436 'count=i' => \( my $list_count ),
437 'a|show-all|list-all|all!' => \$list_all,
438 'include-branches!' => \( my $include_branches= 0 ),
439 'ignore-older-than=s' => \( my $ignore_older_than= "20080101" ),
440 'long-digest!' => \( my $long_digest ),
441 'force!' => \( my $force ),
442  
443 'show-deploy-file!' => \( my $show_deploy_file ),
444 'show-prefix' => \( my $show_prefix ),
445 'show-hook-dir' => \( my $show_hook_dir ),
446  
447 'skip_hooks' => \( $SKIP_HOOKS ),
448  
449 'v|verbose+' => \( $VERBOSE= ($ENV{GIT_DEPLOY_VERBOSE} || 0) ),
450 'help|?' => \( my $help ),
451 'man' => \( my $man ),
452 0 ▶ 'V|version' => sub { print "$0 v" . ($Git::Deploy::VERSION || "Git") . "\n"; exit },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$Git::Deploy::VERSION || 'Git'
l!l
00
MC/DC0%0/1
$Git::Deploy::VERSION || 'Git'
$Git::Deploy::VERSION
Truth table0%0/2
A
A= $Git::Deploy::VERSION
Aresult
11
00
453 19 ▶) or pod2usage(2);
Branch: 1 branch
BranchTrueFalseTotal
&GetOptions("m|message=s", \my @message, "prefix=s", \(my $prefix = ""), "deploy-file-name=s", \my $deploy_file_name, "to-mail=s", \(my $to_mail = $ENV{"LIVE_EMAIL_ADDR"} || get_config("announce-mail", "none")), "date-fmt=s", \(my $date_fmt = "%Y%m%d-%H%M%S"), "check-clean!", \$check_clean, "remote!", \$use_remote, "remote-site=s", \(my $remote_site = "origin"), "remote-branch=s", \(my $remote_branch = ""), "make-tag", \my $make_tag, "show-tag", \my $show_tag, "tag-only", \my $tag_only, "show-list|list!", \my $list, "count=i", \my $list_count, "a|show-all|list-all|all!", \$list_all, "include-branches!", \(my $include_branches = 0), "ignore-older-than=s", \(my $ignore_older_than = 20080101), "long-digest!", \my $long_digest, "force!", \my $force, "show-deploy-file!", \my $show_deploy_file, "show-prefix", \my $show_prefix, "show-hook-dir", \my $show_hook_dir, "skip_hooks", \$main::SKIP_HOOKS, "v|verbose+", \($main::VERBOSE = $ENV{"GIT_DEPLOY_VERBOSE"} || 0), "help|?", \my $help, "man", \my $man, "V|version", sub { print "$0 v" . ($Git::Deploy::VERSION || "Git") . "\n"; exit; } ) or pod2usage(2) 19 0 19
Condition40%2/5
$ENV{'LIVE_EMAIL_ADDR'} || get_config('announce-mail', 'none')
l!l&&r!l&&!r
0190
$ENV{'GIT_DEPLOY_VERBOSE'} || 0
l!l
019
MC/DC0%0/2
$ENV{'LIVE_EMAIL_ADDR'} || get_config('announce-mail', 'none')
$ENV{'LIVE_EMAIL_ADDR'} get_config('announce-mail', 'none')
MC/DC0%0/1
$ENV{'GIT_DEPLOY_VERBOSE'} || 0
$ENV{'GIT_DEPLOY_VERBOSE'}
Truth table33%1/3
A || B
A= $ENV{'LIVE_EMAIL_ADDR'}B= get_config('announce-mail', 'none')
ABresult
1X1
011
000
Truth table50%1/2
A
A= $ENV{'GIT_DEPLOY_VERBOSE'}
Aresult
11
00
454 19 ▶pod2usage(1) if $help;
Branch: 1 branch
BranchTrueFalseTotal
if $help 0 19 19
455 19 ▶pod2usage( -exitstatus => 0, -verbose => 2 ) if $man;
Branch: 1 branch
BranchTrueFalseTotal
if $man 0 19 19
456  
457 19 my $action= shift @ARGV;
458 19 ▶$action= "" if !defined $action;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $action 0 19 19
459 19 ▶if ( @ARGV and !$git_wrap{$action} and !$custom_options{$action}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@ARGV and not $git_wrap{$action} and not $custom_options{$action}) 0 19 19
Condition66%4/6
@ARGV and not $git_wrap{$action} and not $custom_options{$action}
!ll&&!rl&&r
1810
@ARGV and not $git_wrap{$action}
!ll&&!rl&&r
1801
MC/DC0%0/3
@ARGV and not $git_wrap{$action} and not $custom_options{$action}
@ARGV not $git_wrap{$action} not $custom_options{$action}
Truth table50%2/4
A and not(B) and not(C)
A= @ARGVB= not $git_wrap{$action}C= not $custom_options{$action}
ABCresult
0XX0
10X0
1100
1111
460 0 my $p= shift @ARGV;
461 0 ▶ $prefix ||= $p;
Condition0%0/3
$prefix ||= $p
l!l&&r!l&&!r
000
MC/DC0%0/2
$prefix ||= $p
$prefix $p
Truth table0%0/3
A ||= B
A= $prefixB= $p
ABresult
1X1
011
000
462 }
463 19 ▶pod2usage("It looks like you used the option '$prefix' after the action. You must put the options first.") if $prefix=~/^-/;
Branch: 1 branch
BranchTrueFalseTotal
if $prefix =~ /^-/ 0 19 19
464 19 ▶if ($action) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action) 19 0 19
465 pod2usage("Unknown action: $action")
466 19 ▶ if not $legal_action{ lc $action };
Branch: 1 branch
BranchTrueFalseTotal
unless $legal_action{lc $action} 0 19 19
467 19 $action= $legal_action{ lc $action };
468  
469 # set some special default flags for a specific action.
470 19 ▶ if ( $action eq 'show' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($action eq 'show') { } 0 19 19
elsif ($action eq 'showtag') { } 1 18 19
elsif ($action eq 'revert' or $action eq 'start') { } 3 15 18
471 0 $check_clean= 0;
472 0 $list_all= 1;
473 0 $use_remote= 0;
474 }
475 elsif ( $action eq 'showtag' ) {
476 1 $list_all= 1;
477 1 $list_count= 1;
478 1 $tag_only= 1;
479 1 $use_remote= 0;
480 1 $check_clean= 0;
481 }
482 ▶ elsif ( $action eq 'revert' or $action eq 'start' ) {
Condition100%3/3
$action eq "revert" or $action eq "start"
l!l&&r!l&&!r
1215
MC/DC100%2/2
$action eq "revert" or $action eq "start"
$action eq "revert" $action eq "start"
Truth table100%3/3
A or B
A= $action eq "revert"B= $action eq "start"
ABresult
1X1
011
000
483 3 $list_all= 0;
484 }
485 }
486  
487  
488 # test that we actually are in a git repository before we do anything non argument processing related
489 19 init_gitdir();
490  
491  
492 # Don't let users invoke us with a wrong umask
493 19 ▶if (defined(my $require= get_config_int("restrict-umask",undef))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $require = get_config_int("restrict-umask", undef))) 0 19 19
494 0 my $umask= umask;
495 0 ▶ if ( $umask != $require ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($umask != $require) 0 0 0
496 0 _die sprintf( "Your umask is not set properly; got %04o instead of %04o\n", $umask, $require);
497 }
498 }
499  
500  
501 # do some defaulting
502  
503 19 ▶$VERBOSE++ if $action;
Branch: 1 branch
BranchTrueFalseTotal
if $action 19 0 19
504 19 ▶$list= 1 if !$action;
Branch: 1 branch
BranchTrueFalseTotal
unless $action 0 19 19
505  
506 19 ▶$prefix ||= get_config('tag-prefix','');
Condition33%1/3
$prefix ||= get_config("tag-prefix", "")
l!l&&r!l&&!r
0190
MC/DC0%0/2
$prefix ||= get_config("tag-prefix", "")
$prefix get_config("tag-prefix", "")
Truth table33%1/3
A ||= B
A= $prefixB= get_config("tag-prefix", "")
ABresult
1X1
011
000
507 19 ▶$to_mail= 'silent'
Branch: 1 branch
BranchTrueFalseTotal
if $prefix =~ /debug-deploy/i 0 19 19
508 if $prefix =~ /debug-deploy/i;
509 19 ▶$remote_site= "none"
Branch: 1 branch
BranchTrueFalseTotal
unless $use_remote 1 18 19
510 if !$use_remote;
511 19 ▶$list ||= "all"
Branch: 1 branch
BranchTrueFalseTotal
if $list_all 1 18 19
Condition50%1/2
$list ||= "all"
l!l
01
MC/DC0%0/1
$list ||= "all"
$list
Truth table50%1/2
A
A= $list
Aresult
11
00
512 if $list_all;
513 19 ▶$list_count= 20 if !defined $list_count;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $list_count 18 1 19
514 ###################################################################################
515 # Handle --show and --list style options. This precludes any type of rollout step
516 # from occuring.
517  
518 # read the start tag files from disk.
519 19 my $start_tag= fetch_tag_info( 'start' );
520 19 my $rollout_tag= fetch_tag_info( 'rollout' );
521  
522 # show options can not be mixed together ...
523 19 ▶if ($show_prefix) {
Branch: 1 branch
BranchTrueFalseTotal
if ($show_prefix) 0 19 19
524 0 ▶ if ($prefix) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prefix) { } 0 0 0
525 0 ▶ print $prefix, ( $prefix && -t STDOUT ) ? "\n" : "";
Branch: 1 branch
BranchTrueFalseTotal
$prefix && -t STDOUT ? : 0 0 0
Condition0%0/3
$prefix and -t STDOUT
!ll&&!rl&&r
000
MC/DC0%0/2
$prefix and -t STDOUT
$prefix -t STDOUT
Truth table0%0/3
A and B
A= $prefixB= -t STDOUT
ABresult
0X0
100
111
526 0 exit(0);
527 }
528 else {
529 0 _warn "No prefix detected\n";
530 0 exit(1);
531 }
532 }
533  
534 19 ▶if ($show_hook_dir) {
Branch: 1 branch
BranchTrueFalseTotal
if ($show_hook_dir) 0 19 19
535  
536 0 ▶ if (my $hook_dir = get_hook_dir($prefix, 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $hook_dir = get_hook_dir($prefix, 1)) { } 0 0 0
537 0 print $hook_dir, "\n";
538 0 exit(0);
539 }
540 else {
541 0 _warn "No hook dir detected\n";
542 0 exit(1);
543 }
544 }
545  
546 19 ▶if ($show_deploy_file) {
Branch: 1 branch
BranchTrueFalseTotal
if ($show_deploy_file) 0 19 19
547 0 ▶ $deploy_file_name ||= get_deploy_file_name();
Condition0%0/3
$deploy_file_name ||= get_deploy_file_name()
l!l&&r!l&&!r
000
MC/DC0%0/2
$deploy_file_name ||= get_deploy_file_name()
$deploy_file_name get_deploy_file_name()
Truth table0%0/3
A ||= B
A= $deploy_file_nameB= get_deploy_file_name()
ABresult
1X1
011
000
548 0 ▶ if ($start_tag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start_tag) 0 0 0
549 0 _warn "Rollout in progress. The deploy file <$deploy_file_name> is not valid.\n";
550 0 exit(1);
551 }
552 0 my $deploy_file_text= read_deploy_file($deploy_file_name);
553 0 ▶ if ($deploy_file_text) {
Branch: 1 branch
BranchTrueFalseTotal
if ($deploy_file_text) { } 0 0 0
554 0 ▶ print $deploy_file_text, ( $deploy_file_text && -t STDOUT ) ? "\n" : "";
Branch: 1 branch
BranchTrueFalseTotal
$deploy_file_text && -t STDOUT ? : 0 0 0
Condition0%0/3
$deploy_file_text and -t STDOUT
!ll&&!rl&&r
000
MC/DC0%0/2
$deploy_file_text and -t STDOUT
$deploy_file_text -t STDOUT
Truth table0%0/3
A and B
A= $deploy_file_textB= -t STDOUT
ABresult
0X0
100
111
555 0 exit(0);
556 }
557 else {
558 0 ▶ if (-e $deploy_file_name and !-r $deploy_file_name) {
Branch: 2 branches
BranchTrueFalseTotal
if (-e $deploy_file_name and not -r $deploy_file_name) { } 0 0 0
elsif (not -e $deploy_file_name) { } 0 0 0
Condition0%0/3
-e $deploy_file_name and not -r $deploy_file_name
!ll&&!rl&&r
000
MC/DC0%0/2
-e $deploy_file_name and not -r $deploy_file_name
-e $deploy_file_name not -r $deploy_file_name
Truth table0%0/3
A and not(B)
A= -e $deploy_file_nameB= not -r $deploy_file_name
ABresult
0X0
100
111
559 0 _warn "The deploy file <$deploy_file_name> exists, but we can't read it\n";
560 } elsif (!-e $deploy_file_name) {
561 0 _warn "The deploy file <$deploy_file_name> doesn't exist.\n" .
562 "\n" .
563 "You should run:\n" .
564 "\n" .
565 "\tgit-deploy start\n" .
566 "\n" .
567 "Followed by:\n" .
568 "\n" .
569 "\tgit-deploytool sync\n" .
570 "\n" .
571 "To create one and sync out your code\n";
572 } else {
573 0 _warn "The deploy file <$deploy_file_name> is not valid\n";
574 }
575 0 exit(1);
576 }
577 }
578  
579 19 ▶if ( $action eq 'status' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "status") 5 14 19
580 5 my $status= read_rollout_status();
581 5 my $exit_val= 0;
582 5 ▶ if ( !$start_tag || !$status ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $start_tag && $status) { } 5 0 5
elsif (not $rollout_tag) { } 0 0 0
Condition33%1/3
$start_tag && $status
!ll&&!rl&&r
500
MC/DC0%0/2
$start_tag && $status
$start_tag $status
Truth table33%1/3
A && B
A= $start_tagB= $status
ABresult
0X0
100
111
583 5 ▶ if (my $message= check_rollouts_blocked($force,"no_die")) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $message = check_rollouts_blocked($force, 'no_die')) { } 0 5 5
584 0 _say $message;
585 0 $exit_val= 3;
586 } else {
587 5 _say "No $prefix deployment currently in progress\n";
588 5 $exit_val= 0;
589 }
590 }
591 elsif ( !$rollout_tag ) {
592 0 _say "$prefix rollout started - not synced yet ($start_tag)\n";
593 0 $exit_val= 1;
594 }
595 else {
596 0 _say "$prefix rollout tagged - awaiting sync? ($start_tag..$rollout_tag)\n";
597 0 $exit_val= 2;
598 }
599 5 ▶ if ($status) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status) 0 5 5
600 0 _say $status;
601 }
602 5 exit($exit_val);
603 }
604  
605 14 my @extra= @ARGV;
606 14 ▶if ( $git_wrap{$action} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($git_wrap{$action}) 2 12 14
607 2 ▶ if ( !$start_tag ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $start_tag) { } 2 0 2
elsif ($rollout_tag) { } 0 0 0
608 2 exit;
609 }
610 elsif ($rollout_tag) {
611 0 exec( "git", $action, @extra, "$rollout_tag..$start_tag" );
612 }
613 else {
614 0 exec( "git", $action, @extra, "$start_tag..HEAD" );
615 }
616 }
617  
618 12 ▶if ( $action eq 'modified' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "modified") 0 12 12
619 0 show_modified( $start_tag, $rollout_tag );
620 0 exit;
621 }
622  
623 12 my $revert_choice;
624 12 ▶if ( $action eq 'revert' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "revert") 1 11 12
625 1 ▶ if (@ARGV) {
Branch: 1 branch
BranchTrueFalseTotal
if (@ARGV) 1 0 1
626 1 $revert_choice = shift @ARGV;
627 }
628 }
629  
630 12 ▶if (@ARGV) {
Branch: 1 branch
BranchTrueFalseTotal
if (@ARGV) 0 12 12
631 0 pod2usage("Too many arguments.");
632 }
633  
634 # we want this before actions are handled. but not for show_actions that
635 # dont involve looking at the git tree.
636 12 ▶if ( !$prefix ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($prefix) 0 12 12
637 0 _die "It appears you have not specified a tag prefix and it is not configured either.\n"
638 . "You can use:\n\n"
639 . " git config deploy.tag-prefix PREFIX\n\n"
640 . "to configure this repository for deployment, or provide one on the command line.\n";
641 }
642  
643 12 ▶if ( $list || $show_tag ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list or $show_tag) 1 11 12
Condition66%2/3
$list or $show_tag
l!l&&r!l&&!r
1011
MC/DC50%1/2
$list or $show_tag
$list $show_tag
Truth table66%2/3
A or B
A= $listB= $show_tag
ABresult
1X1
011
000
644 1 my $head_refs= do_get_name_list( $ignore_older_than, $list, $list_all, $include_branches );
645  
646 0 print_refs( {
647 list => $list,
648 long_digest => $long_digest,
649 count => $list_count,
650 prefix => $prefix,
651 tag_only => $tag_only,
652 action => $action,
653 },
654 $head_refs
655 );
656 0 exit(0);
657 }
658  
659 11 ▶if (!$force and (!get_config("user.name","") or !get_config("user.email",""))) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($force or get_config("user.name", "") and get_config("user.email", "")) 10 1 11
Condition50%3/6
$force or get_config("user.name", "") and get_config("user.email", "")
l!l&&r!l&&!r
1010
get_config("user.name", "") and get_config("user.email", "")
!ll&&!rl&&r
1000
MC/DC33%1/3
$force or get_config("user.name", "") and get_config("user.email", "")
$force get_config("user.name", "") get_config("user.email", "")
Truth table50%2/4
A or B and C
A= $forceB= get_config("user.name", "")C= get_config("user.email", "")
ABCresult
1XX1
0111
00X0
0100
660 10 _die "Please make sure you execute:\n\n"
661 . " git config --global user.name 'Your Name'\n"
662 . " git config --global user.email 'email\@host.com'\n"
663 . "\n"
664 . "before you use this tool";
665 }
666  
667 1 ▶if ($check_clean) {
Branch: 1 branch
BranchTrueFalseTotal
if ($check_clean) 1 0 1
668 1 ▶ _info "Checking working directory\n" if $VERBOSE > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $main::VERBOSE > 1 0 1 1
669 1 do_pre_checks($prefix,$action);
670 }
671  
672 0 ▶if ( $make_tag or $action eq 'tag' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($make_tag or $action eq "tag") 0 0 0
Condition0%0/3
$make_tag or $action eq "tag"
l!l&&r!l&&!r
000
MC/DC0%0/2
$make_tag or $action eq "tag"
$make_tag $action eq "tag"
Truth table0%0/3
A or B
A= $make_tagB= $action eq "tag"
ABresult
1X1
011
000
673 0 do_fetch($remote_site);
674 0 ▶ _die "You aren't allowed to make tags for the prefix '$prefix' (can-make-tags is 'false')"
Branch: 1 branch
BranchTrueFalseTotal
unless get_config_bool("can-make-tags", "false") 0 0 0
675 unless get_config_bool("can-make-tags",'false');
676 0 ▶ if ( !@message and $action eq 'tag' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @message and $action eq "tag") 0 0 0
Condition0%0/3
not @message and $action eq "tag"
!ll&&!rl&&r
000
MC/DC0%0/2
not @message and $action eq "tag"
not @message $action eq "tag"
Truth table0%0/3
not(A) and B
A= not @messageB= $action eq "tag"
ABresult
0X0
100
111
677 0 ▶ if ( $prefix =~ /^(\w+?)_?prt$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prefix =~ /^(\w+?)_?prt$/) { } 0 0 0
678 0 push @message, "\U$1\E Production Readyness Test Release";
679 }
680 else {
681 0 push @message, "Working tag for '$prefix'\n";
682 }
683 }
684 0 ▶ _die "Message is not optional with --make-tag" unless @message;
Branch: 1 branch
BranchTrueFalseTotal
unless @message 0 0 0
685 0 ▶ my $tag= make_dated_tag( $prefix, $date_fmt, @message )
Branch: 1 branch
BranchTrueFalseTotal
my $tag = make_dated_tag($prefix, $date_fmt, @message) or &_die("Failed to create tag!\n") 0 0 0
686 or _die "Failed to create tag!\n";
687 0 ▶ if ( $action eq 'tag' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "tag") 0 0 0
688  
689 # and push any tags that might have been created
690 0 write_deploy_file( $tag, \@message, $deploy_file_name );
691 0 push_tag( $remote_site, $tag );
692 }
693 0 print "$tag\n";
694 0 exit(0);
695 }
696  
697 ###################################################################################
698 # At this point we are have been asked to do a rollout step and we are in a clean
699 # working directory. Depending on which $action they request we do different things
700  
701 0 my $host= hostname();
702 0 my @actions= ($action);
703 0 ▶if ( $action eq 'release' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "release") 0 0 0
704 0 ▶ _die "You arent allowed to use the 'release' action for the prefix '$prefix'"
Branch: 1 branch
BranchTrueFalseTotal
unless get_config_bool("can-make-tags", "false") 0 0 0
705 unless get_config_bool("can-make-tags",'false');
706 0 push @actions, "finish";
707 }
708  
709 0 ▶while (@actions) {
Branch: 1 branch
BranchTrueFalseTotal
if (@actions) 0 0 0
710 0 my $final_words= ""; #any messages to display at the end of the rollout - distinct from yay message
711 0 my $action= shift @actions;
712 0 my $start_tag= fetch_tag_info( 'start' );
713 0 my $rollout_tag= fetch_tag_info( 'rollout' );
714 0 my ( $subject, $body );
715 0 my $start_time= time;
716 0 _info "Starting step '$action' at ", strftime("%Y-%m-%d %H:%M:%S",localtime($start_time)),"\n";
717 0 push_timings("gdt_action_$action");
718  
719 ######################################################
720 0 ▶ if ( $action eq 'start' or $action eq 'revert' or $action eq 'hotfix' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($action eq 'start' or $action eq 'revert' or $action eq 'hotfix') { } 0 0 0
elsif ($action eq 'sync' or $action eq 'release' or $action eq 'manual-sync') { } 0 0 0
elsif ($action eq 'abort') { } 0 0 0
elsif ($action eq 'finish') { } 0 0 0
Condition0%0/6
$action eq "start" or $action eq "revert" or $action eq "hotfix"
l!l&&r!l&&!r
000
$action eq "start" or $action eq "revert"
l!l&&r!l&&!r
000
MC/DC0%0/3
$action eq "start" or $action eq "revert" or $action eq "hotfix"
$action eq "start" $action eq "revert" $action eq "hotfix"
Truth table0%0/4
A or B or C
A= $action eq "start"B= $action eq "revert"C= $action eq "hotfix"
ABCresult
1XX1
01X1
0011
0000
721  
722 # these will die if there is a problem
723 0 execute_deploy_hooks(
724 action => $action,
725 phase => "pre-start",
726 prefix => $prefix,
727 );
728  
729 0 should_write_timings();
730  
731 write_rollout_status(
732 "start", $force,
733 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
734 0 _checktag( $action, 'start', $start_tag, 0 );
735 0 _checktag( $action, 'rollout', $rollout_tag, 0 );
736 0 } ); # this will die if there is a problem
737 0 do_fetch($remote_site);
738  
739 # $list_all is always false here.
740 0 ($start_tag)= @{ do_get_name_list( $ignore_older_than, $list, $list_all, $include_branches ) };
741  
742 0 ▶ if ($start_tag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start_tag) { } 0 0 0
743 0 ▶ _info "Working directory was checked out to tag '$start_tag', will restore this tag on abort\n"
Branch: 1 branch
BranchTrueFalseTotal
if $main::VERBOSE 0 0 0
744 if $VERBOSE;
745 }
746 else {
747 0 ▶ if ( !@message ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@message) 0 0 0
748 0 push @message, "tagged as restore point if you abort deployment procedure for $prefix";
749 }
750 0 ▶ $start_tag= make_dated_tag( $prefix, $date_fmt, @message )
Branch: 1 branch
BranchTrueFalseTotal
$start_tag = make_dated_tag($prefix, $date_fmt, @message) or &_die("Failed to create tag!\n") 0 0 0
751 or _die "Failed to create tag!\n";
752 }
753 0 store_tag_info( 'start', $start_tag );
754 0 my $sha1= get_commit_for_name($start_tag);
755 0 my $first_line;
756 # these will die if there is a problem
757 0 execute_deploy_hooks(
758 action => $action,
759 phase => "pre-pull",
760 prefix => $prefix,
761 start_tag => $start_tag,
762 );
763 0 _info "Pruning dead remote branches";
764 0 _info `git remote prune origin`;
765 0 ▶ if ( $action eq 'revert' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($action eq 'revert') { } 0 0 0
elsif ($action eq 'start') { } 0 0 0
elsif ($action eq 'hotfix') { } 0 0 0
766 0 execute_log_hooks(
767 action => $action,
768 prefix => $prefix,
769 log_announce => 1,
770 log_level => "info",
771 log_message => "Starting revert of '$prefix' from $start_tag"
772 );
773 0 push @actions,
774 do_interactive_revert( $list_count, $prefix, $action, $ignore_older_than, $include_branches,
775 $deploy_file_name, \@message, \$subject, \$body, $revert_choice, $date_fmt );
776 0 $first_line= "\nRevert procedure has started. You should now be checked out to the chosen commit.\n";
777 }
778 elsif ( $action eq 'start' ) {
779 0 execute_log_hooks(
780 action => $action,
781 prefix => $prefix,
782 log_announce => 1,
783 log_level => "info",
784 log_message => "Starting rollout of '$prefix', previous rollout was $start_tag",
785 );
786  
787 0 pull( $remote_site, $remote_branch );
788 0 $first_line= "\nDeploy procedure has started. You should now be checked out to the latest commit.\n"
789 . "You should now restart your server if necessary, and test the deploy\n",;
790  
791 # these will die if there is a problem
792 execute_deploy_hooks(
793 action => $action,
794 phase => $_,
795 prefix => $prefix,
796 start_tag => $start_tag,
797 0 ) for qw(post-pull post-tree-update);
798 0 $subject= "Starting live rollout of $prefix";
799 0 $body=
800 "About to start rollout procedure for $prefix on $host\n\n"
801 . "The currently deployed checkout is $start_tag $sha1\n\n"
802 . read_deploy_file($deploy_file_name);
803 }
804 elsif ( $action eq 'hotfix' ) {
805 0 execute_log_hooks(
806 action => $action,
807 prefix => $prefix,
808 log_announce => 1,
809 log_level => "info",
810 log_message => "Starting hotfix of '$prefix', previous rollout was $start_tag",
811  
812 );
813  
814 0 $first_line=
815 "\nHotfix deploy procedure has started. You are still checked out to the same commit as before.\n"
816 . "You should make, test, and commit whatever modifications you need.\n";
817  
818 0 $subject= "Starting *hotfix* rollout of $prefix";
819 0 $body= "A hotfix rollout procedure has begun for $prefix on $host\n\n"
820 . "The initial state of the checkout is $start_tag $sha1\n\n"
821 . read_deploy_file($deploy_file_name);
822 }
823  
824  
825 0 ▶ if ( !@actions ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@actions) 0 0 0
826 0 _tell $first_line, "\n",
827 "If you want abandon this deploy use\n\n",
828 " git-deploy abort\n\n",
829 "When you are ready to rollout use\n\n",
830 " git-deploy sync\n\n",
831 "to continue with the rollout process.\n\n",
832 "You can view a list of modified files with\n\n",
833 " git-deploy modified\n\n",
834 "Or view a diff or log of changes with the normal git options with\n\n",
835 " git-deploy diff [options]\n",
836 " git-deploy log [options]\n\n",
837 ;
838 }
839  
840 execute_deploy_hooks(
841 0 action => $action,
842 phase => "post-start",
843 prefix => $prefix,
844 start_tag => $start_tag,
845 );
846 ######################################################
847 }
848 ▶ elsif ( $action eq 'sync' or $action eq 'release' or $action eq 'manual-sync' ) {
Condition0%0/6
$action eq "sync" or $action eq "release" or $action eq "manual-sync"
l!l&&r!l&&!r
000
$action eq "sync" or $action eq "release"
l!l&&r!l&&!r
000
MC/DC0%0/3
$action eq "sync" or $action eq "release" or $action eq "manual-sync"
$action eq "sync" $action eq "release" $action eq "manual-sync"
Truth table0%0/4
A or B or C
A= $action eq "sync"B= $action eq "release"C= $action eq "manual-sync"
ABCresult
1XX1
01X1
0011
0000
849 0 should_write_timings();
850 write_rollout_status(
851 $action, $force,
852 0 ▶ sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
853 0 _checktag( $action, 'start', $start_tag, 1 );
854 0 _checktag( $action, 'rollout', $rollout_tag, 0 );
855  
856 0 my $commit_for_HEAD = get_commit_for_name("HEAD");
857 0 my $commit_for_start = get_commit_for_name($start_tag);
858 0 ▶ if ( $action ne 'release'
Branch: 1 branch
BranchTrueFalseTotal
if ($action ne "release" and $commit_for_HEAD eq $commit_for_start) 0 0 0
Condition0%0/3
$action ne "release" and $commit_for_HEAD eq $commit_for_start
!ll&&!rl&&r
000
MC/DC0%0/2
$action ne "release" and $commit_for_HEAD eq $commit_for_start
$action ne "release" $commit_for_HEAD eq $commit_for_start
Truth table0%0/3
A and B
A= $action ne "release"B= $commit_for_HEAD eq $commit_for_start
ABresult
0X0
100
111
859 and $commit_for_HEAD eq $commit_for_start )
860 {
861 0 ▶ if ($force) {
Branch: 1 branch
BranchTrueFalseTotal
if ($force) { } 0 0 0
862 0 _warn "--force enabling rolling out same thing you had when you started\n";
863 }
864 else {
865 0 _die "It seems like there is nothing to $action\n",
866 "The commit for HEAD ($commit_for_HEAD)\n",
867 "Is the same as the start commit ($commit_for_start, tag $start_tag)\n",
868 "\n",
869 "If you really want to rollout the same thing ",
870 "you started with then use the --force option\n\n";
871 }
872 }
873  
874 # this will die if there are unpushed commits
875 0 check_for_unpushed_commits( $remote_site, $remote_branch, $force );
876  
877 # these will die if there is a problem
878 0 execute_deploy_hooks(
879 action => $action,
880 phase => "pre-sync",
881 prefix => $prefix,
882 start_tag => $start_tag,
883 );
884 0 } );
885 0 do_fetch($remote_site);
886  
887 0 ▶ if ( !@message ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@message) 0 0 0
888 0 push @message, "rollout of $prefix ($start_tag..%TAG)";
889 }
890 0 ▶ $rollout_tag= make_dated_tag( $prefix, $date_fmt, @message )
Branch: 1 branch
BranchTrueFalseTotal
$rollout_tag = make_dated_tag($prefix, $date_fmt, @message) or &_die("Failed to create tag!\n") 0 0 0
891 or _die "Failed to create tag!\n";
892 0 store_tag_info( 'rollout', $rollout_tag );
893 0 my $deploy_text= write_deploy_file( $rollout_tag, \@message, $deploy_file_name );
894  
895 0 $subject= "Syncing $prefix to $rollout_tag from $host (replacing $start_tag)";
896  
897 0 my $shortlog_cmd= qq(git shortlog --format='%h %s' $start_tag..$rollout_tag);
898 0 my $diff_cmd= qq(git diff --stat $start_tag..$rollout_tag);
899 0 $body=
900 "$subject\n\n"
901 . read_deploy_file($deploy_file_name)
902 . "\n-----------\n"
903 . "Commits Involved (By Author):\n"
904 . "$shortlog_cmd\n"
905 . `$shortlog_cmd`
906 . "\n-----------\n"
907 . "$diff_cmd\n"
908 . `$diff_cmd`;
909  
910 #XXX: we want a mail here. as it's a pretty useful mail.
911  
912 0 ▶ if ( $action ne 'manual-sync' and my $sync_hook= get_sync_hook( $prefix ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($action ne 'manual-sync' and my $sync_hook = get_sync_hook($prefix)) { } 0 0 0
elsif ($action ne 'release') { } 0 0 0
Condition0%0/3
$action ne "manual-sync" and my $sync_hook = get_sync_hook($prefix)
!ll&&!rl&&r
000
MC/DC0%0/2
$action ne "manual-sync" and my $sync_hook = get_sync_hook($prefix)
$action ne "manual-sync" my $sync_hook = get_sync_hook($prefix)
Truth table0%0/3
A and B
A= $action ne "manual-sync"B= my $sync_hook = get_sync_hook($prefix)
ABresult
0X0
100
111
913  
914 0 _info "A sync hook has been defined for this server!\n",
915 "Will use '$sync_hook' to synchronize code to remote servers\n",
916 "If the synchronization completes successfully then your rollout\n",
917 "session will be automatically 'finished' and you will be done.\n",
918 ;
919  
920 0 execute_log_hooks(
921 action => $action,
922 prefix => $prefix,
923 log_announce => 1,
924 log_level => "info",
925 log_message => $subject,
926 );
927  
928 do_sync_with_sync_hook(
929 sync_hook => $sync_hook,
930 env => {
931 rollout_tag => $rollout_tag,
932 start_tag => $start_tag,
933 deploy_file => get_deploy_file_name($deploy_file_name),
934 deploy_text => $deploy_text,
935 rollout_prefix => $prefix,
936 },
937 actions => \@actions,
938 push_action_if_ok => "finish",
939 disable_further_actions_if_not_ok => 1,
940 0 ▶ ) or do {
Branch: 1 branch
BranchTrueFalseTotal
do_sync_with_sync_hook("sync_hook", $sync_hook, "env", {"rollout_tag", $rollout_tag, "start_tag", $start_tag, "deploy_file", get_deploy_file_name($deploy_file_name), "deploy_text", $deploy_text, "rollout_prefix", $prefix}, "actions", \@actions, "push_action_if_ok", "finish", "disable_further_actions_if_not_ok", 1) or do { $final_words = "Sync step for '${prefix}' was only partially successful,\n" . "tag '${rollout_tag}' has been created but NOT properly synced!" } 0 0 0
941 0 $final_words= "Sync step for '$prefix' was only partially successful,\n"
942 . "tag '$rollout_tag' has been created but NOT properly synced!";
943 };
944 }
945 elsif ( $action ne 'release' ) {
946 0 _tell "You must now hand execute the synchronization process and then execute git-deploy finish\n";
947  
948 0 execute_log_hooks(
949 action => $action,
950 prefix => $prefix,
951 log_announce => 1,
952 log_level => "info",
953 log_message => "sync step ignored for $prefix rollout - manual sync required",
954 );
955 }
956  
957 # these will die if there is a problem - should they be executed if the sync failed?
958 execute_deploy_hooks(
959 0 action => $action,
960 phase => "post-sync",
961 prefix => $prefix,
962 start_tag => $start_tag,
963 rollout_tag => $rollout_tag,
964 );
965 ######################################################
966 }
967 elsif ( $action eq 'abort' ) {
968 0 should_write_timings();
969  
970 # this will die if there is a problem
971 write_rollout_status(
972 $action, $force,
973 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
974 0 _checktag( $action, 'abort', $start_tag, 1 );
975 0 } );
976  
977 0 _say "Rolling back to $start_tag\n";
978 0 reset_to_name( $action, $start_tag, $prefix );
979 0 my $deploy_text= "";
980 0 ▶ if ( !$rollout_tag ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $rollout_tag) { } 0 0 0
981  
982 #they havent synced yet
983 0 $subject= "Aborted $prefix rollout";
984 0 $body= "Update of $prefix from $host has been aborted.\n\n" . "Servers are still at $start_tag\n\n";
985 0 ▶ if ( !@message ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@message) 0 0 0
986 0 push @message, "Aborted rollout, returned to $start_tag";
987 }
988 0 $deploy_text= write_deploy_file( $start_tag, \@message, $deploy_file_name );
989 0 execute_log_hooks(
990 action => $action,
991 prefix => $prefix,
992 log_announce => 1,
993 log_level => "info",
994 log_message => "Aborting $prefix rollout, no synchronization performed",
995 );
996 }
997 else {
998 0 do_fetch($remote_site);
999 # they did sync it
1000 0 my $new_start_tag;
1001 0 ▶ if ( !@message ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@message) 0 0 0
1002 0 push @message, "Aborted rollout of $rollout_tag, rolled back to $start_tag";
1003 }
1004 0 ▶ $new_start_tag= make_dated_tag( $prefix, $date_fmt, @message )
Branch: 1 branch
BranchTrueFalseTotal
$new_start_tag = make_dated_tag($prefix, $date_fmt, @message) or &_die("Failed to create tag!\n") 0 0 0
1005 or _die "Failed to create tag!\n";
1006 0 $deploy_text= write_deploy_file( $new_start_tag, \@message, $deploy_file_name );
1007  
1008 0 $subject= "Rollout of $rollout_tag has been aborted, rolled back to $start_tag!";
1009 0 $body=
1010 "Update of $prefix from $host has been aborted.\n\n"
1011 . "Servers will be rolled back to $start_tag with a new tag of $new_start_tag\n\n"
1012 . "New deploy status:"
1013 . read_deploy_file($deploy_file_name);
1014  
1015 0 ▶ if ( my $sync_hook= get_sync_hook( $prefix ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sync_hook = get_sync_hook($prefix)) { } 0 0 0
1016 0 _info "Will automatically execute $sync_hook to update servers\n";
1017 0 execute_log_hooks(
1018 action => $action,
1019 prefix => $prefix,
1020 log_announce => 1,
1021 log_level => "info",
1022 log_message => "$prefix rollout aborted after a partial or full sync, syncing previous tag $start_tag (via rollback tag $new_start_tag)",
1023 );
1024 do_sync_with_sync_hook(
1025 sync_hook => $sync_hook,
1026 env => {
1027 rollout_tag => $new_start_tag,
1028 start_tag => $start_tag,
1029 deploy_file => get_deploy_file_name($deploy_file_name),
1030 deploy_text => $deploy_text,
1031 rollout_prefix => $prefix,
1032 },
1033 actions => \@actions,
1034 0 ▶ ) or do {
Branch: 1 branch
BranchTrueFalseTotal
do_sync_with_sync_hook("sync_hook", $sync_hook, "env", {"rollout_tag", $new_start_tag, "start_tag", $start_tag, "deploy_file", get_deploy_file_name($deploy_file_name), "deploy_text", $deploy_text, "rollout_prefix", $prefix}, "actions", \@actions) or do { $final_words = "Rollback of '${start_tag}' has only been partially successful.\n" . "New tag '${new_start_tag}' has not been fully synchronized.\n" } 0 0 0
1035 0 $final_words= "Rollback of '$start_tag' has only been partially successful.\n"
1036 . "New tag '$new_start_tag' has not been fully synchronized.\n";
1037 };
1038 } else {
1039 0 execute_log_hooks(
1040 action => $action,
1041 prefix => $prefix,
1042 log_announce => 1,
1043 log_level => "warning",
1044 log_message => "Aborting $prefix rollout after a partial sync WITHOUT RESYNCING REVERTED CODE",
1045 );
1046 0 _tell "You must execute the server update step yourself after start.\n";
1047 }
1048 }
1049  
1050 0 execute_deploy_hooks(
1051 action => $action,
1052 phase => "post-abort",
1053 prefix => $prefix,
1054 );
1055  
1056 0 unlink_rollout_status_file();
1057  
1058 ######################################################
1059 }
1060 elsif ( $action eq 'finish' ) {
1061 0 execute_log_hooks(
1062 action => $action,
1063 prefix => $prefix,
1064 log_announce => 1,
1065 log_level => "info",
1066 log_message => "Finished $prefix rollout session for $rollout_tag",
1067 );
1068 write_rollout_status(
1069 $action, $force,
1070 0 ▶ sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1071 0 _checktag( $action, 'start', $start_tag, 1 );
1072 0 _checktag( $action, 'rollout', $rollout_tag, 1 );
1073  
1074 0 ▶ if ( get_commit_for_name("HEAD") ne get_commit_for_name($rollout_tag) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (get_commit_for_name("HEAD") ne get_commit_for_name($rollout_tag)) 0 0 0
1075 0 _die "Something is wrong.\n"
1076 . "Your rollout tag '$rollout_tag' does not correspond to HEAD\n"
1077 . "When performing the 'finish' step HEAD should match the rollout tag\n";
1078 }
1079  
1080 # this will _die if there is a problem
1081 0 } );
1082  
1083 0 $subject= "Finished $prefix rollout";
1084 0 $body=
1085 "Update of $prefix from $host is now complete.\n\n"
1086 . "Servers now updated from $start_tag to $rollout_tag\n\n"
1087 . read_deploy_file($deploy_file_name);
1088 0 unlink_rollout_status_file();
1089  
1090 0 _info "Pruning dead remote branches";
1091 0 _info `git remote prune origin`;
1092 0 _info "Packing references for speedup next time";
1093 0 _info `git pack-refs`;
1094  
1095 # XXX: this is a cheap an easy way to silence the mails for this action
1096 # by request of liz and the teamleaders.
1097 ######################################################
1098 0 _say "Looks like you are all done! Have a nice day.";
1099 }
1100 else {
1101 0 _die "panic: unhanded \$action: $action\n";
1102 }
1103  
1104 # send out the announcement mail if requested
1105 {
1106 0 my $send_mail_config_param = "send-mail-on-$action";
1107 0 ▶ if (get_config_bool($send_mail_config_param, "false")) {
Branch: 1 branch
BranchTrueFalseTotal
if (get_config_bool($send_mail_config_param, 'false')) { } 0 0 0
1108 0 ▶ if ( my $send_to_mail= get_to_mail($action,$to_mail) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $send_to_mail = get_to_mail($action, $to_mail)) 0 0 0
1109 0 send_email_with_sendmail(
1110 to_mail => $send_to_mail,
1111 subject => $subject,
1112 body => $body,
1113 );
1114 0 _say "Mailed '$action' mail to $send_to_mail\n";
1115 }
1116 } else {
1117 0 _info "Not sending mail on action '$action'. This can be configured with the '$send_mail_config_param'";
1118 }
1119 }
1120  
1121 0 _info "Step '$action' finished. Started at ", strftime("%Y-%m-%d %H:%M:%S",localtime($start_time)),
1122 "; took ",(time - $start_time)," seconds to complete\n";
1123 0 ▶ if ($final_words) {
Branch: 1 branch
BranchTrueFalseTotal
if ($final_words) { } 0 0 0
1124 0 my $msg = "'$action' for '$prefix' had problems\n$final_words";
1125 0 _warn $msg;
1126 0 execute_log_hooks(
1127 action => $action,
1128 prefix => $prefix,
1129 log_announce => 1,
1130 log_level => "warning",
1131 log_message => $msg,
1132 );
1133 0 exit(71);
1134 } else {
1135 0 my $msg = "'$action' for '$prefix' completed successfully";
1136 0 ▶ $rollout_tag and $msg .= " (now at $rollout_tag)";
Branch: 1 branch
BranchTrueFalseTotal
$rollout_tag and $msg .= " (now at $rollout_tag)" 0 0 0
1137 0 _yay "$msg\n";
1138 0 ▶ execute_log_hooks(
Branch: 1 branch
BranchTrueFalseTotal
if $action eq "sync" or $action eq "manual-sync" 0 0 0
Condition0%0/3
$action eq "sync" or $action eq "manual-sync"
l!l&&r!l&&!r
000
MC/DC0%0/2
$action eq "sync" or $action eq "manual-sync"
$action eq "sync" $action eq "manual-sync"
Truth table0%0/3
A or B
A= $action eq "sync"B= $action eq "manual-sync"
ABresult
1X1
011
000
1139 action => $action,
1140 prefix => $prefix,
1141 log_announce => 1,
1142 log_level => "info",
1143 log_message => $msg,
1144 ) if $action eq 'sync' or
1145 $action eq 'manual-sync';
1146 }
1147 }
1148  
1149 # and push any tags that might have been created
1150 0 push_timings("gdt_push_tags");
1151 0 push_tags( $remote_site );
1152  
1153 0 push_timings("gdt_end");
1154 0 write_timings();
1155  
1156 0 exit(0);
1157  
1158 __END__
« lib/Git/Deploy.pm ↑ Summary blib/lib/Git/Deploy/Question.pm »