diff --git a/utilities/releaseScripts/3_create_tags.rb b/utilities/releaseScripts/3_create_tags.rb index f20cf77e..9ffec871 100644 --- a/utilities/releaseScripts/3_create_tags.rb +++ b/utilities/releaseScripts/3_create_tags.rb @@ -25,15 +25,11 @@ def create_tag(dir, branch, tag, message) "git pull", "git tag -a #{tag} -m '#{message}'" ] - cmds.delete_at(1) unless is_remote_branch?(branch) + cmds.delete_at(1) unless remote_branch_exists?(path, branch) approve_and_execute(cmds, "in #{path}") end end -def is_remote_branch?(branch) - ! `git branch --list -a origin/#{branch}`.strip.empty? -end - # # ------------------------------------------------------------------------------------ # Main method diff --git a/utilities/releaseScripts/4_extract_files.rb b/utilities/releaseScripts/4_extract_files.rb index d223158f..0df62855 100644 --- a/utilities/releaseScripts/4_extract_files.rb +++ b/utilities/releaseScripts/4_extract_files.rb @@ -26,7 +26,7 @@ def export_files(vivo_path, vitro_path, tag, branch, export_dir) cmds = ["git checkout #{branch}", "git pull", ] - cmds.delete_at(1) unless is_remote_branch?(branch) + cmds.delete_at(1) unless remote_branch_exists?(path, branch) approve_and_execute(cmds, "in #{path}") end @@ -34,7 +34,7 @@ def export_files(vivo_path, vitro_path, tag, branch, export_dir) cmds = ["git checkout #{branch}", "git pull", ] - cmds.delete_at(1) unless is_remote_branch?(branch) + cmds.delete_at(1) unless remote_branch_exists?(path, branch) approve_and_execute(cmds, "in #{path}") end @@ -47,10 +47,6 @@ def export_files(vivo_path, vitro_path, tag, branch, export_dir) ]) end -def is_remote_branch?(branch) - ! `git branch --list -a origin/#{branch}`.strip.empty? -end - # # ------------------------------------------------------------------------------------ # Main method diff --git a/utilities/releaseScripts/_common.rb b/utilities/releaseScripts/_common.rb index b175b3e1..c29278f1 100644 --- a/utilities/releaseScripts/_common.rb +++ b/utilities/releaseScripts/_common.rb @@ -239,13 +239,22 @@ end def branch_exists?(dir, branch) Dir.chdir(dir) do |path| - ! `git branch --list #{branch}`.strip.empty? + re = Regexp.new("\\b#{branch}\\b") + `git branch`.index(re) + end +end + +def remote_branch_exists?(dir, branch) + Dir.chdir(dir) do |path| + re = Regexp.new("remotes/origin/#{branch}\\b") + `git branch -a`.index(re) end end def tag_exists?(dir, tag) Dir.chdir(dir) do |path| - !`git tag --list #{tag}`.strip.empty? + re = Regexp.new("\\b#{tag}\\b") + `git tag`.index(re) end end