lib/rconf/configurators/git_repo_configurator.rb in rconf-0.7.6 vs lib/rconf/configurators/git_repo_configurator.rb in rconf-0.7.8
- old
+ new
@@ -17,57 +17,42 @@
register :git_repo
description 'Clone git repository and build if needed'
- settings :repo => 'git repo URL',
- :tag => 'git tag or branch or sha that should be checked out',
- :install_path => 'Path where git repo should be cloned to',
- :build_commands => 'Comma separated list of commands to run in repo after clone',
- :only_if => 'Ruby lambda expression that should return true to proceed ' +
- 'with the cloning / build if defined'
+ 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, :install_path
+ validate_has_settings :repo, :path
# Clone git repo and run build commands if given
#
# === Return
# true:: Always return true
def run
- if only_if.nil? || only_if.call
- report_check("Cloning #{repo} into #{install_path}")
- if File.exist?(install_path)
- FileUtils.mv(install_path, "#{install_path}_old")
- post_note "Had to move pre-existing #{install_path} to #{install_path}_old"
+ 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
- Command.execute('git', 'clone', repo, install_path,
- :abort_on_failure => "Failed to clone #{repo} into #{install_path}")
- Command.execute('git', 'checkout', tag) if tag
+ 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 build_commands
- report_check "Building"
- Dir.chdir(install_path) do
- build_commands.split(',').each do |c|
- c.lstrip!
- args = c.split(' ') + [ { :abort_on_failure => "#{c} failed" } ]
- Command.execute(*args)
- end
+ 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
end
true
end
- # Clone on Windows
- #
- # === Return
- # true:: Always return true
- def run_windows
- # TBD
- end
-
end
end
-
-