lib/rconf/configurators/git_repo_configurator.rb in rconf-0.8.3 vs lib/rconf/configurators/git_repo_configurator.rb in rconf-0.8.4

- old
+ new

@@ -22,34 +22,41 @@ settings :repo => 'git repo URL', :path => 'Path where git repo should be cloned to', :tag => 'git tag or branch or sha that should be checked out ("master" by default)' validate_has_settings :repo, :path + + # Check whether repo was already cloned + # + # === Return + # true:: If repo was already cloned + # false:: Otherwise + def check_linux + File.exist?(path) && File.exist?(File.join(path, '.git')) + end + alias :check_darwin :check_linux + alias :check_windows :check_linux # Clone git repo and run build commands if given # # === Return # true:: Always return true def run_linux if File.exist?(path) - unless File.exist?(File.join(path, '.git')) - FileUtils.mv(path, "#{path}_old") - post_note "Had to move #{path} to #{path}_old" - end + FileUtils.mv(path, "#{path}_old") + post_note "Had to move #{path} to #{path}_old" end - unless File.exist?(path) - report_check("Cloning #{repo} into #{path}") - Command.execute('git', 'clone', repo, path, - :abort_on_failure => "Failed to clone #{repo} into #{path}") - report_success - if tag - report_check("Checking out #{tag}") - Dir.chdir(path) do - Command.execute('git', 'checkout', tag, - :abort_on_failure => "Failed to checkout #{tag}") - end - report_success + report_check("Cloning #{repo} into #{path}") + Command.execute('git', 'clone', repo, path, + :abort_on_failure => "Failed to clone #{repo} into #{path}") + report_success + if tag + report_check("Checking out #{tag}") + Dir.chdir(path) do + Command.execute('git', 'checkout', tag, + :abort_on_failure => "Failed to checkout #{tag}") end + report_success end true end alias :run_darwin :run_linux