adapt the release scripts to an older Git client

This commit is contained in:
Jim Blake 2013-10-18 14:48:28 -04:00
parent 3df439c4a7
commit 02280e6171
3 changed files with 14 additions and 13 deletions

View file

@ -25,15 +25,11 @@ def create_tag(dir, branch, tag, message)
"git pull", "git pull",
"git tag -a #{tag} -m '#{message}'" "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}") approve_and_execute(cmds, "in #{path}")
end end
end end
def is_remote_branch?(branch)
! `git branch --list -a origin/#{branch}`.strip.empty?
end
# #
# ------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------
# Main method # Main method

View file

@ -26,7 +26,7 @@ def export_files(vivo_path, vitro_path, tag, branch, export_dir)
cmds = ["git checkout #{branch}", cmds = ["git checkout #{branch}",
"git pull", "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}") approve_and_execute(cmds, "in #{path}")
end end
@ -34,7 +34,7 @@ def export_files(vivo_path, vitro_path, tag, branch, export_dir)
cmds = ["git checkout #{branch}", cmds = ["git checkout #{branch}",
"git pull", "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}") approve_and_execute(cmds, "in #{path}")
end end
@ -47,10 +47,6 @@ def export_files(vivo_path, vitro_path, tag, branch, export_dir)
]) ])
end end
def is_remote_branch?(branch)
! `git branch --list -a origin/#{branch}`.strip.empty?
end
# #
# ------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------
# Main method # Main method

View file

@ -239,13 +239,22 @@ end
def branch_exists?(dir, branch) def branch_exists?(dir, branch)
Dir.chdir(dir) do |path| 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
end end
def tag_exists?(dir, tag) def tag_exists?(dir, tag)
Dir.chdir(dir) do |path| Dir.chdir(dir) do |path|
!`git tag --list #{tag}`.strip.empty? re = Regexp.new("\\b#{tag}\\b")
`git tag`.index(re)
end end
end end