From 5b8309bcbccde6b2369a444201676f9cc1d7d383 Mon Sep 17 00:00:00 2001 From: j2blake Date: Fri, 13 Sep 2013 17:24:59 -0400 Subject: [PATCH] VIVO-262 Complete the push script. Add more checking to extract_files. --- utilities/releaseScripts/4_extract_files.rb | 25 +++++++++++-- utilities/releaseScripts/8_push_changes.rb | 39 +++++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 utilities/releaseScripts/8_push_changes.rb diff --git a/utilities/releaseScripts/4_extract_files.rb b/utilities/releaseScripts/4_extract_files.rb index 6b480338..d223158f 100644 --- a/utilities/releaseScripts/4_extract_files.rb +++ b/utilities/releaseScripts/4_extract_files.rb @@ -21,7 +21,23 @@ require '_common' # # Get the VIVO files and the Vitro files, and remove the .git directories. # -def export_files(vivo_path, vitro_path, tag, export_dir) +def export_files(vivo_path, vitro_path, tag, branch, export_dir) + Dir.chdir(vivo_path) do |path| + cmds = ["git checkout #{branch}", + "git pull", + ] + cmds.delete_at(1) unless is_remote_branch?(branch) + approve_and_execute(cmds, "in #{path}") + end + + Dir.chdir(vitro_path) do |path| + cmds = ["git checkout #{branch}", + "git pull", + ] + cmds.delete_at(1) unless is_remote_branch?(branch) + approve_and_execute(cmds, "in #{path}") + end + approve_and_execute([ "rm -Rf #{File.expand_path("..", export_dir)}", "mkdir -pv #{export_dir}", @@ -31,6 +47,10 @@ def export_files(vivo_path, vitro_path, tag, export_dir) ]) end +def is_remote_branch?(branch) + ! `git branch --list -a origin/#{branch}`.strip.empty? +end + # # ------------------------------------------------------------------------------------ # Main method @@ -39,6 +59,7 @@ end begin tag = Settings.tag_name + branch = Settings.branch_name vivo_path = Settings.vivo_path vitro_path = Settings.vitro_path export_dir = Settings.export_dir @@ -54,7 +75,7 @@ begin get_permission_and_go(p) do puts "Building export area" - export_files(vivo_path, vitro_path, tag, export_dir) + export_files(vivo_path, vitro_path, tag, branch, export_dir) end rescue BadState puts "#{$!.message} - Aborting." diff --git a/utilities/releaseScripts/8_push_changes.rb b/utilities/releaseScripts/8_push_changes.rb new file mode 100644 index 00000000..3bb46eba --- /dev/null +++ b/utilities/releaseScripts/8_push_changes.rb @@ -0,0 +1,39 @@ +=begin +-------------------------------------------------------------------------------- + +Push any branches, tags, or merges back to GitHub. + +-------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- +=end + +$: << File.dirname(File.expand_path(__FILE__)) +require '_common' + +# +# Merge the maintenance branch to the master branch and create the tag. +# +def push_to_origin(repo_path) + Dir.chdir(repo_path) do |path| + approve_and_execute(["git push --all", "git push --tags"], "in #{path}") + end +end + +# +# ------------------------------------------------------------------------------------ +# Main method +# ------------------------------------------------------------------------------------ +# + +begin + vivo_path = Settings.vivo_path + vitro_path = Settings.vitro_path + + get_permission_and_go("OK to push changes to the origin?") do + puts "Merging tags" + push_to_origin(vivo_path) + push_to_origin(vitro_path) + end +rescue BadState + puts "#{$!.message} - Aborting." +end