Rakefiles: simplify `push()` function
authorJan Vrany <jan.vrany@labware.com>
Mon, 27 Jun 2022 15:13:20 +0100
changeset 325 7d9550327b8d
parent 324 980eac9a7a1d
child 326 42a9250a00b2
Rakefiles: simplify `push()` function ...as there's no need to mess up with remotes.
rakelib/workflow.rake
--- a/rakelib/workflow.rake	Fri Dec 20 22:16:22 2019 +0000
+++ b/rakelib/workflow.rake	Mon Jun 27 15:13:20 2022 +0100
@@ -25,23 +25,18 @@
           :pass => pass,
       }
       paths = hg.paths
-      remote_used = remote
-      if remote_used == 'upstream'
-        remote_used = 'canonical' unless paths['upstream']
-      elsif remote_used == 'staging'
-        unless paths['staging']
-          puts ''
-          puts "!! repository #{hg.path} has not staging repository defined - skipping !!"
-          puts ''
-          return
-        end
+      unless paths[remote]
+        puts ''
+        puts "!! repository #{hg.path} has no #{remote} repository defined - skipping !!"
+        puts ''
+        return
       end
 
       # STC and librun are special - never push them automatically
-      # to upstream / canonical repo, must be done manually. This is 
-      # mainly beacuse there are on separate protected repositories 
+      # to upstream / default repo, must be done manually. This is
+      # mainly beacuse there are on separate protected repositories
       # not accessible without a special setup. Sigh...
-      if ((pkg.name == 'stx:stc') or (pkg.name == 'stx:librun')) and ((remote_used == 'upstream') or (remote_used == 'canonical'))
+      if ((pkg.name == 'stx:stc') or (pkg.name == 'stx:librun')) and ((remote == 'upstream') or (remote == 'canonical'))
         if !review_only
           puts ''
           puts "== Skipping push of #{pkg.name} - you must push manually =="
@@ -51,9 +46,9 @@
         has_changes_in_this_repo = false
         if review_only or STDIN.tty?
           opts[:rev] = '.'
-          remote_url = hg.paths[remote_used] || remote_used
+          remote_url = hg.paths[remote] || remote
           bookmark = hg.bookmark
-          hg.outgoing(remote_used, **opts) do | status, stdout |
+          hg.outgoing(remote, **opts) do | status, stdout |
             case status.exitstatus
             when 0
               puts ''
@@ -73,7 +68,7 @@
         if not review_only
           if not STDIN.tty? or (has_changes_in_this_repo and yesNO("Push to #{remote_url}")) then
             (push_bookmark && bookmark) ? (opts[:bookmarks] = ['.']) : (opts[:rev] = '.') # bookmark can be uninitialized
-            hg.push(remote_used, **opts)
+            hg.push(remote, **opts)
             has_changes = true
           end
         end