VIVO-272 Refactor scripts: get_permission_and_go()
This commit is contained in:
parent
419af234c4
commit
508f88a7c5
7 changed files with 52 additions and 66 deletions
|
@ -38,21 +38,14 @@ begin
|
||||||
vivo_path = Settings.vivo_path
|
vivo_path = Settings.vivo_path
|
||||||
vitro_path = Settings.vitro_path
|
vitro_path = Settings.vitro_path
|
||||||
|
|
||||||
|
raise BadState.new("Branches are not created for test candidates.") if is_test_candidate?()
|
||||||
raise BadState.new("Branch #{branch} already exists in VIVO.") if branch_exists?(vivo_path, branch)
|
raise BadState.new("Branch #{branch} already exists in VIVO.") if branch_exists?(vivo_path, branch)
|
||||||
raise BadState.new("Branch #{branch} already exists in Vitro.") if branch_exists?(vitro_path, branch)
|
raise BadState.new("Branch #{branch} already exists in Vitro.") if branch_exists?(vitro_path, branch)
|
||||||
|
|
||||||
puts
|
get_permission_and_go("OK to create branches named '#{branch}'?") do
|
||||||
yn = prompt("OK to create branches named '#{branch}' (y/n)")
|
|
||||||
if yn.downcase == 'y'
|
|
||||||
puts
|
|
||||||
puts "Creating branches"
|
puts "Creating branches"
|
||||||
create_branch(vivo_path, branch)
|
create_branch(vivo_path, branch)
|
||||||
create_branch(vitro_path, branch)
|
create_branch(vitro_path, branch)
|
||||||
puts
|
|
||||||
else
|
|
||||||
puts
|
|
||||||
puts "OK - forget it."
|
|
||||||
puts
|
|
||||||
end
|
end
|
||||||
rescue BadState
|
rescue BadState
|
||||||
puts "#{$!.message} - Aborting."
|
puts "#{$!.message} - Aborting."
|
||||||
|
|
|
@ -52,18 +52,10 @@ begin
|
||||||
raise BadState.new("Tag #{tag} already exists in VIVO.") if tag_exists?(vivo_path, tag)
|
raise BadState.new("Tag #{tag} already exists in VIVO.") if tag_exists?(vivo_path, tag)
|
||||||
raise BadState.new("Tag #{tag} already exists in Vitro.") if tag_exists?(vitro_path, tag)
|
raise BadState.new("Tag #{tag} already exists in Vitro.") if tag_exists?(vitro_path, tag)
|
||||||
|
|
||||||
puts
|
get_permission_and_go("OK to create tags named '#{tag}' '#{message}'?") do
|
||||||
yn = prompt("OK to create tags named '#{tag}' '#{message}' (y/n)")
|
|
||||||
if yn.downcase == 'y'
|
|
||||||
puts
|
|
||||||
puts "Creating tags"
|
puts "Creating tags"
|
||||||
create_tag(vivo_path, branch, tag, message)
|
create_tag(vivo_path, branch, tag, message)
|
||||||
create_tag(vitro_path, branch, tag, message)
|
create_tag(vitro_path, branch, tag, message)
|
||||||
puts
|
|
||||||
else
|
|
||||||
puts
|
|
||||||
puts "OK - forget it."
|
|
||||||
puts
|
|
||||||
end
|
end
|
||||||
rescue BadState
|
rescue BadState
|
||||||
puts "#{$!.message} - Aborting."
|
puts "#{$!.message} - Aborting."
|
||||||
|
|
|
@ -47,22 +47,14 @@ begin
|
||||||
raise BadState.new("Tag #{tag} doesn't exist in Vitro.") unless tag_exists?(vitro_path, tag)
|
raise BadState.new("Tag #{tag} doesn't exist in Vitro.") unless tag_exists?(vitro_path, tag)
|
||||||
|
|
||||||
if File.directory?(export_dir)
|
if File.directory?(export_dir)
|
||||||
p = "OK to overwrite export area at #{export_dir} ? (y/n)"
|
p = "OK to overwrite export area at #{export_dir} ?"
|
||||||
else
|
else
|
||||||
p = "OK to create export area at #{export_dir} ? (y/n)"
|
p = "OK to create export area at #{export_dir} ?"
|
||||||
end
|
end
|
||||||
|
|
||||||
puts
|
get_permission_and_go(p) do
|
||||||
yn = prompt(p)
|
|
||||||
if yn.downcase == 'y'
|
|
||||||
puts
|
|
||||||
puts "Building export area"
|
puts "Building export area"
|
||||||
export_files(vivo_path, vitro_path, tag, export_dir)
|
export_files(vivo_path, vitro_path, tag, export_dir)
|
||||||
puts
|
|
||||||
else
|
|
||||||
puts
|
|
||||||
puts "OK - forget it."
|
|
||||||
puts
|
|
||||||
end
|
end
|
||||||
rescue BadState
|
rescue BadState
|
||||||
puts "#{$!.message} - Aborting."
|
puts "#{$!.message} - Aborting."
|
||||||
|
|
|
@ -47,23 +47,15 @@ begin
|
||||||
raise BadState.new("Files have not been exported to #{export_dir}") unless File.directory?(export_dir)
|
raise BadState.new("Files have not been exported to #{export_dir}") unless File.directory?(export_dir)
|
||||||
|
|
||||||
if File.exist?(vivo_revision_info_path) || File.exist?(vitro_revision_info_path)
|
if File.exist?(vivo_revision_info_path) || File.exist?(vitro_revision_info_path)
|
||||||
p = "OK to overwrite revision_info at these paths? \n #{vivo_revision_info_path} \n #{vitro_revision_info_path} ? (y/n)"
|
p = "OK to overwrite revision_info at these paths? \n #{vivo_revision_info_path} \n #{vitro_revision_info_path} ?"
|
||||||
else
|
else
|
||||||
p = "OK to write revision_info at these paths? \n #{vivo_revision_info_path} \n #{vitro_revision_info_path} ? (y/n)"
|
p = "OK to write revision_info at these paths? \n #{vivo_revision_info_path} \n #{vitro_revision_info_path} ?"
|
||||||
end
|
end
|
||||||
|
|
||||||
puts
|
get_permission_and_go(p) do
|
||||||
yn = prompt(p)
|
|
||||||
if yn.downcase == 'y'
|
|
||||||
puts
|
|
||||||
puts "Building revision info"
|
puts "Building revision info"
|
||||||
create_revision_info(vivo_path, vivo_revision_info_path, tag)
|
create_revision_info(vivo_path, vivo_revision_info_path, tag)
|
||||||
create_revision_info(vitro_path, vitro_revision_info_path, tag)
|
create_revision_info(vitro_path, vitro_revision_info_path, tag)
|
||||||
puts
|
|
||||||
else
|
|
||||||
puts
|
|
||||||
puts "OK - forget it."
|
|
||||||
puts
|
|
||||||
end
|
end
|
||||||
rescue BadState
|
rescue BadState
|
||||||
puts "#{$!.message} - Aborting."
|
puts "#{$!.message} - Aborting."
|
||||||
|
|
|
@ -50,23 +50,10 @@ begin
|
||||||
raise BadState.new("Revision information file does not exist at #{vivo_revision_info_path}") unless File.exist?(vivo_revision_info_path)
|
raise BadState.new("Revision information file does not exist at #{vivo_revision_info_path}") unless File.exist?(vivo_revision_info_path)
|
||||||
raise BadState.new("Revision information file does not exist at #{vitro_revision_info_path}") unless File.exist?(vitro_revision_info_path)
|
raise BadState.new("Revision information file does not exist at #{vitro_revision_info_path}") unless File.exist?(vitro_revision_info_path)
|
||||||
|
|
||||||
if File.exist?(vivo_revision_info_path) || File.exist?(vitro_revision_info_path)
|
|
||||||
p = "OK to overwrite revision_info at these paths? \n #{vivo_revision_info_path} \n #{vitro_revision_info_path} ? (y/n)"
|
|
||||||
else
|
|
||||||
p = "OK to write revision_info at these paths? \n #{vivo_revision_info_path} \n #{vitro_revision_info_path} ? (y/n)"
|
|
||||||
end
|
|
||||||
|
|
||||||
puts
|
get_permission_and_go("OK to create distribution files in #{export_dir} ?") do
|
||||||
yn = prompt("OK to create distribution files in #{export_dir} ? (y/n)")
|
|
||||||
if yn.downcase == 'y'
|
|
||||||
puts
|
|
||||||
puts "Creating distribution files"
|
puts "Creating distribution files"
|
||||||
create_distribution_files(export_dir, vivo_filename, vitro_filename)
|
create_distribution_files(export_dir, vivo_filename, vitro_filename)
|
||||||
puts
|
|
||||||
else
|
|
||||||
puts
|
|
||||||
puts "OK - forget it."
|
|
||||||
puts
|
|
||||||
end
|
end
|
||||||
rescue BadState
|
rescue BadState
|
||||||
puts "#{$!.message} - Aborting."
|
puts "#{$!.message} - Aborting."
|
||||||
|
|
|
@ -47,18 +47,10 @@ begin
|
||||||
raise BadState.new("Branch #{branch} doesn't exist in VIVO.") unless branch_exists?(vivo_path, branch)
|
raise BadState.new("Branch #{branch} doesn't exist in VIVO.") unless branch_exists?(vivo_path, branch)
|
||||||
raise BadState.new("Branch #{branch} doesn't exist in Vitro.") unless branch_exists?(vitro_path, branch)
|
raise BadState.new("Branch #{branch} doesn't exist in Vitro.") unless branch_exists?(vitro_path, branch)
|
||||||
|
|
||||||
puts
|
get_permission_and_go("OK to merge the #{tag} tags to the master branches?") do
|
||||||
yn = prompt("OK to merge the #{tag} tags to the master branches? (y/n)")
|
|
||||||
if yn.downcase == 'y'
|
|
||||||
puts
|
|
||||||
puts "Merging tags"
|
puts "Merging tags"
|
||||||
merge_branch_to_master(branch, tag, message, vivo_path)
|
merge_branch_to_master(branch, tag, message, vivo_path)
|
||||||
merge_branch_to_master(branch, tag, message, vitro_path)
|
merge_branch_to_master(branch, tag, message, vitro_path)
|
||||||
puts
|
|
||||||
else
|
|
||||||
puts
|
|
||||||
puts "OK - forget it."
|
|
||||||
puts
|
|
||||||
end
|
end
|
||||||
rescue BadState
|
rescue BadState
|
||||||
puts "#{$!.message} - Aborting."
|
puts "#{$!.message} - Aborting."
|
||||||
|
|
|
@ -23,6 +23,10 @@ end
|
||||||
#
|
#
|
||||||
|
|
||||||
class Settings
|
class Settings
|
||||||
|
#
|
||||||
|
# The settings themselves: getters, setters, and validators.
|
||||||
|
#
|
||||||
|
|
||||||
def self.base_directory
|
def self.base_directory
|
||||||
`git config --get --global vivo.release.basedirectory`.strip
|
`git config --get --global vivo.release.basedirectory`.strip
|
||||||
end
|
end
|
||||||
|
@ -102,11 +106,16 @@ class Settings
|
||||||
#
|
#
|
||||||
|
|
||||||
# The name of the maintenance branch. Looks like "maint-rel-4.2" even for releases like "4.2.1"
|
# The name of the maintenance branch. Looks like "maint-rel-4.2" even for releases like "4.2.1"
|
||||||
|
# Test candidates for major releases are built on the develop branch.
|
||||||
def self.branch_name
|
def self.branch_name
|
||||||
label = Settings.confirm_release_label(Settings.release_label)
|
if is_test_candidate?()
|
||||||
major_release = label[0..2]
|
"develop"
|
||||||
|
else
|
||||||
|
release_label = Settings.confirm_release_label(Settings.release_label)
|
||||||
|
major_release = release_label[0..2]
|
||||||
"maint-rel-#{major_release}"
|
"maint-rel-#{major_release}"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# The name of the Git tag. Looks like "rel-1.9-tc2" or "rel-1.9" (for final)
|
# The name of the Git tag. Looks like "rel-1.9-tc2" or "rel-1.9" (for final)
|
||||||
def self.tag_name
|
def self.tag_name
|
||||||
|
@ -165,6 +174,20 @@ class Settings
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------------
|
||||||
|
# Confirmation methods.
|
||||||
|
# ------------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
|
||||||
|
def is_test_candidate?()
|
||||||
|
Settings.confirm_candidate_label(Settings.candidate_label)[0..0] == 't'
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_final_release?()
|
||||||
|
Settings.confirm_candidate_label(Settings.candidate_label) == 'final'
|
||||||
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# ------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------------
|
||||||
# General-purpose methods.
|
# General-purpose methods.
|
||||||
|
@ -181,6 +204,20 @@ def echo_command(c)
|
||||||
`#{c}`
|
`#{c}`
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_permission_and_go(p)
|
||||||
|
puts
|
||||||
|
yn = prompt("#{p} (y/n)")
|
||||||
|
if yn.downcase == 'y'
|
||||||
|
puts
|
||||||
|
yield
|
||||||
|
puts
|
||||||
|
else
|
||||||
|
puts
|
||||||
|
puts "OK - forget it."
|
||||||
|
puts
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def approve_and_execute(cmds, prompt="")
|
def approve_and_execute(cmds, prompt="")
|
||||||
if prompt.empty?
|
if prompt.empty?
|
||||||
puts "Execute these commands?"
|
puts "Execute these commands?"
|
||||||
|
@ -211,3 +248,4 @@ def tag_exists?(dir, tag)
|
||||||
!`git tag --list #{tag}`.strip.empty?
|
!`git tag --list #{tag}`.strip.empty?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue