Permalink
Browse files

Add a "push-hotfix" action to automate hotfix recipe

See Issue #25 - TODO Eliminate busywork from hotfix process.

This is an untested initial attempt at a recipe for this process. It is
interesting as we dont have an easy way currently to the lock a directory
without modifying the logfile. We solve this by holding a lock on the
logfile for the duration of the action.

IOW, this includes code to support a "logless lock". (Quite simple logic
actually).
  • Loading branch information...
1 parent 820d7ef commit 13b5b54055ba01e942e4b352805f23fd6af3751a @demerphq demerphq committed Jan 6, 2013
Showing with 29 additions and 0 deletions.
  1. +20 −0 bin/git-deploy
  2. +9 −0 lib/Git/Deploy.pm
View
@@ -1097,6 +1097,26 @@ while (@actions) {
######################################################
_say "Looks like you are all done! Have a nice day.";
}
+ elsif ( $action eq 'push-hotfix' ) {
+ # get a lock while we work.
+ my $fh= write_rollout_status(
+ $action, $force,
+ sub {
+ _checktag( $action, 'push-hotfix', $start_tag, 1 );
+ }, "return_fh" );
+ my $sha1= get_commit_for_name('HEAD');
+ my $ok= eval {
+ pull($remote_site);
+ push_remote($remote_site);
+ 1;
+ };
+ reset_to_name($action, $sha1, $prefix);
+ if ($ok) {
+ _say "Merged code with upstream and pushed. You should be able to sync now.";
+ } else {
+ _warn "Failed to merge and push. You might need to rerun this command.";
+ }
+ }
else {
_die "panic: unhanded \$action: $action\n";
}
View
@@ -1163,6 +1163,7 @@ BEGIN {
my $status= shift;
my $force= shift;
my $other_checks= shift;
+ my $return_fh= shift;
my ( $lock_dir, $lock_file )= _rollout_lock_dir_and_file();
@@ -1235,6 +1236,11 @@ BEGIN {
$somethings_wrong->("Can't $status in the current state:");
}
}
+ if ( $status eq 'push-hotfix' ) {
+ if ( @file != 1 ) {
+ $somethings_wrong->("Can't $status once you have sync'ed");
+ }
+ }
if ( $file[0] !~ /\t\Q$ENV{USER}\E$/ ) {
$somethings_wrong->("Someone else is doing a rollout. You cannot proceed.");
}
@@ -1246,6 +1252,9 @@ BEGIN {
flock( $out_fh, LOCK_EX | LOCK_NB )
or _die "Failed to lock file:$!\nSomebody already rolling out?\n";
$other_checks->();
+
+ return $out_fh if $return_fh;
+
my $status_line= join(
"\t",
"$status:", # must be first

0 comments on commit 13b5b54

Please sign in to comment.