]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
auto run 'git submodule update --init' on leap platform if needed
authorelijah <elijah@riseup.net>
Sat, 27 Oct 2012 22:56:48 +0000 (15:56 -0700)
committerelijah <elijah@riseup.net>
Sat, 27 Oct 2012 22:56:48 +0000 (15:56 -0700)
leap_cli.gemspec
lib/leap_cli/commands/deploy.rb
lib/leap_cli/util.rb

index 0368e6e83d62ef7ee07879f0d57b793c8d6599cd..ecabe451a23a4ff83561cb794a7ca74643e24b5a 100644 (file)
@@ -53,7 +53,7 @@ spec = Gem::Specification.new do |s|
   #s.add_runtime_dependency('supply_drop')
 
   # misc gems
-  s.add_runtime_dependency('ya2yaml')   # pure ruby yaml, so we can better control output.
+  s.add_runtime_dependency('ya2yaml')   # pure ruby yaml, so we can better control output. see https://github.com/afunai/ya2yaml
   s.add_runtime_dependency('json_pure') # pure ruby json, so we can better control output.
   s.add_runtime_dependency('gpgme')     # not essential, but used for some minor stuff in adding sysadmins
 
index 8febe4db97e66ff2f81d56f19a81fe4d240af4fc..31ae053f6b9422258961a805ef2efe5f48c7f31a 100644 (file)
@@ -6,6 +6,8 @@ module LeapCli
     arg_name '<node filter>'
     command :deploy do |c|
       c.action do |global_options,options,args|
+        init_submodules
+
         nodes = manager.filter!(args)
         if nodes.size > 1
           say "Deploying to these nodes: #{nodes.keys.join(', ')}"
@@ -13,6 +15,7 @@ module LeapCli
             quit! "OK. Bye."
           end
         end
+
         ssh_connect(nodes) do |ssh|
           # directory setup
           ssh.leap.mkdir("/etc/leap")
@@ -46,5 +49,20 @@ module LeapCli
       end
     end
 
+    private
+
+    def init_submodules
+      Dir.chdir Path.platform do
+        statuses = assert_run! "git submodule status"
+        statuses.strip.split("\n").each do |status_line|
+          if status_line =~ /^-/
+            submodule = status_line.split(' ')[1]
+            progress "Updating submodule #{submodule}"
+            assert_run! "git submodule update --init #{submodule}"
+          end
+        end
+      end
+    end
+
   end
 end
\ No newline at end of file
index fdbdc8a4c72447fc85c1c8091fd78a7451d28062..3b0c3345700c3161ec999486268a84245e0457f6 100644 (file)
@@ -55,11 +55,15 @@ module LeapCli
     # assert that the command is run without an error.
     # if successful, return output.
     #
-    def assert_run!(cmd, message)
-      log2(" * run: #{cmd}")
+    def assert_run!(cmd, message=nil)
       cmd = cmd + " 2>&1"
       output = `#{cmd}`
-      assert!($?.success?, message)
+      unless $?.success?
+        log1(" * run: #{cmd}")
+        log1(" * FAILED: (exit #{$?}) #{output}")
+      else
+        log2(" * run: #{cmd}")
+      end
       return output
     end