lib/repositories.rb in forj-0.0.21 vs lib/repositories.rb in forj-0.0.22
- old
+ new
@@ -19,31 +19,40 @@
require 'fileutils'
require 'require_relative'
require_relative 'yaml_parse.rb'
include YamlParse
+require_relative 'log.rb'
+include Logging
#
# Repositories module
#
module Repositories
def clone_repo
- definitions = YamlParse::get_values('../lib/catalog.yaml')
- maestro_url = definitions['default']['maestro']
+ current_dir = Dir.pwd
+ forj_dir = File.expand_path(File.dirname(__FILE__))
+ Dir.chdir(forj_dir)
- home = File.expand_path('~')
- path = home + '/.hpcloud/'
+ definitions = YamlParse::get_values('../lib/catalog.yaml')
+ maestro_url = definitions['default']['maestro']
- begin
- if File.directory?(path)
- if File.directory?(path + 'maestro')
- FileUtils.rm_r path + 'maestro'
+ home = File.expand_path('~')
+ path = home + '/.forj/'
+
+ begin
+ if File.directory?(path)
+ if File.directory?(path + 'maestro')
+ FileUtils.rm_r path + 'maestro'
+ end
+ Logging.info('cloning the maestro repo')
+ Git.clone(maestro_url, 'maestro', :path => path)
end
- Git.clone(maestro_url, 'maestro', :path => path)
+ rescue => e
+ puts format('Error while cloning the repo from %{maestro_url}', maestro_url: maestro_url)
+ puts 'If this error persist you could clone the repo manually in ~/.forj/'
+ Logging.error(e.message)
end
- rescue
- puts format('Error while cloning the repo from %{maestro_url}', maestro_url: maestro_url)
- puts 'If this error persist you could clone the repo manually in ~/.hpcloud/'
+ Dir.chdir(current_dir)
end
- end
-end
+end
\ No newline at end of file