]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
make platform constraints optional (ask the user if they really want to do it).
authorelijah <elijah@riseup.net>
Thu, 9 Oct 2014 19:19:40 +0000 (12:19 -0700)
committerelijah <elijah@riseup.net>
Thu, 9 Oct 2014 19:19:40 +0000 (12:19 -0700)
lib/leap_cli/commands/deploy.rb

index b78f130ce1d37a04f5f8d259ede6c1de7af3ec42..b4e37794c9b3e0fdb23bf7154cd46a0cded0ad10 100644 (file)
@@ -110,30 +110,34 @@ module LeapCli
       # check version
       if provider.platform['version']
         if !Leap::Platform.version_in_range?(provider.platform.version)
-          bail!("The platform is pinned to a version range of '#{provider.platform.version}' "+
+          say("The platform is pinned to a version range of '#{provider.platform.version}' "+
             "by the `platform.version` property in #{provider_json}, but the platform "+
             "(#{Path.platform}) has version #{Leap::Platform.version}.")
+          quit!("OK. Bye.") unless agree("Do you really want to deploy from the wrong version? ")
         end
       end
 
       # check branch
       if provider.platform['branch']
         if !is_git_directory?(Path.platform)
-          bail!("The platform is pinned to a particular branch by the `platform.branch` property "+
+          say("The platform is pinned to a particular branch by the `platform.branch` property "+
             "in #{provider_json}, but the platform directory (#{Path.platform}) is not a git repository.")
+          quit!("OK. Bye.") unless agree("Do you really want to deploy anyway? ")
         end
         unless provider.platform.branch == current_git_branch(Path.platform)
-          bail!("The platform is pinned to branch '#{provider.platform.branch}' by the `platform.branch` property "+
+          say("The platform is pinned to branch '#{provider.platform.branch}' by the `platform.branch` property "+
             "in #{provider_json}, but the current branch is '#{current_git_branch(Path.platform)}' " +
             "(for directory '#{Path.platform}')")
+          quit!("OK. Bye.") unless agree("Do you really want to deploy from the wrong branch? ")
         end
       end
 
       # check commit
       if provider.platform['commit']
         if !is_git_directory?(Path.platform)
-          bail!("The platform is pinned to a particular commit range by the `platform.commit` property "+
+          say("The platform is pinned to a particular commit range by the `platform.commit` property "+
             "in #{provider_json}, but the platform directory (#{Path.platform}) is not a git repository.")
+          quit!("OK. Bye.") unless agree("Do you really want to deploy anyway? ")
         end
         current_commit = current_git_commit(Path.platform)
         Dir.chdir(Path.platform) do
@@ -144,9 +148,10 @@ module LeapCli
           commit_range = commit_range.split("\n")
           if !commit_range.include?(current_commit) &&
               provider.platform.commit.split('..').first != current_commit
-            bail!("The platform is pinned via the `platform.commit` property in #{provider_json} " +
+            say("The platform is pinned via the `platform.commit` property in #{provider_json} " +
               "to a commit in the range #{provider.platform.commit}, but the current HEAD " +
               "(#{current_commit}) is not in that range.")
+            quit!("OK. Bye.") unless agree("Do you really want to deploy from the wrong commit? ")
           end
         end
       end