Commit 2ad5e407d70abb47cd7be992c48c20e1cf1dc458

Thomas de Grivel 2023-02-26T02:52:19

rbpkg_ci_mux

diff --git a/bin/rbpkg_ci b/bin/rbpkg_ci
index b1e5113..3723cca 100755
--- a/bin/rbpkg_ci
+++ b/bin/rbpkg_ci
@@ -37,9 +37,8 @@ def rbpkg_ci
     cmd = "rm -rf #{sh_quote(Rbpkg.ci_dir)}"
     verbose(1, cmd)
     raise "command failed: #{cmd.inspect}" unless system(cmd)
-    Rbpkg.ci_init
-    shift
-    exit if $ARGS == []
+    Rbpkg::Log.ok_all
+    exit 0
   when "-h"
     usage
   when "--help"
@@ -53,11 +52,11 @@ def rbpkg_ci
   commit = $ARGS[0] ? shift : nil
   usage unless $ARGS == []
   Rbpkg::Repos.repo(repo).ci(branch, commit)
+  Rbpkg::Log.ok_all
 end
 
 begin
   rbpkg_ci
-  Rbpkg::Log.ok_all
 rescue => error
   verbose(-1, error.backtrace.reverse.join("\n"))
   verbose(-1, "#{error.class.name}: #{error.message}")
diff --git a/bin/rbpkg_ci_mux b/bin/rbpkg_ci_mux
index 3a27a49..ff822a1 100755
--- a/bin/rbpkg_ci_mux
+++ b/bin/rbpkg_ci_mux
@@ -33,57 +33,53 @@ end
 
 def rbpkg_ci_mux
   clean = false
-  remote = true
   upgrade = false
-  while case $ARGS[0]
-        when "--clean"
-          clean = true
-          shift
-        when "-h"
-          usage
-        when "--help"
-          usage
-        when "--no-remote"
-          remote = false
-          shift
-        when "--upgrade"
-          Rbpkg.upgrade_self
-          shift
-          upgrade = true
-        end
+  while (case $ARGS[0]
+         when "--clean"
+           shift
+           cmd = "rm -rf #{sh_quote(Rbpkg.ci_dir)}"
+           verbose(1, cmd)
+           raise "command failed: #{cmd.inspect}" unless system(cmd)
+           Rbpkg.ci_init
+           hosts = $ARGS
+           hosts.each do |host|
+             cmd! "ssh #{sh_quote(host)} rbpkg/bin/rbpkg_ci --clean"
+           end
+           Rbpkg::Log.ok_all
+           exit 0
+         when "-h"
+           usage
+         when "--help"
+           usage
+         when "--no-remote"
+           Rbpkg.ci_mux
+           Rbpkg::Log.ok_all
+           exit 0
+         when "--upgrade"
+           Rbpkg.upgrade_self
+           shift
+           hosts = $ARGS
+           hosts.each do |host|
+             cmd! "ssh #{sh_quote(host)} rbpkg/bin/rbpkg upgrade"
+           end
+           Rbpkg::Log.ok_all
+           exit 0
+         end)
     true
   end
   repo = shift
   branch = shift
   commit = shift
-  threads = []
   hosts = $ARGS
-  if clean
-    cmd = "rm -rf #{sh_quote(Rbpkg.ci_dir)}"
-    verbose(1, cmd)
-    raise "command failed: #{cmd.inspect}" unless system(cmd)
-    Rbpkg.ci_init
-    if remote
-      hosts.each do |host|
-        cmd! "ssh #{sh_quote(host)} rbpkg/bin/rbpkg_ci --clean"
-      end
-    end
-  end
-  if upgrade && remote
-    hosts.each do |host|
-      cmd! "ssh #{sh_quote(host)} rbpkg/bin/rbpkg upgrade"
+  Thread.report_on_exception = false
+  threads = []
+  hosts.each do |host|
+    threads << Thread.new do
+      Rbpkg.ci_remote(repo, branch, commit, host)
     end
   end
-  if remote
-    hosts.each do |host|
-      Thread.report_on_exception = false
-      threads << Thread.new do
-        Rbpkg.ci_remote(repo, branch, commit, host)
-      end
-    end
-    threads.each do |t|
-      t.join
-    end
+  threads.each do |t|
+    t.join
   end
   Rbpkg.ci_mux
 end