Class: Fhcap::Tasks::Repo::Checkout
- Defined in:
- lib/fhcap/tasks/repo/checkout.rb
Instance Attribute Summary collapse
-
#fallback_gitref ⇒ Object
readonly
Returns the value of attribute fallback_gitref.
-
#gitref ⇒ Object
readonly
Returns the value of attribute gitref.
-
#remote ⇒ Object
readonly
Returns the value of attribute remote.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Attributes inherited from TaskBase
#config, #options, #thor, #verbose
Instance Method Summary collapse
-
#initialize(options) ⇒ Checkout
constructor
A new instance of Checkout.
- #run ⇒ Object
Methods inherited from TaskBase
#ask_config, #color_pad, #exit_with_error, #set_color, #suppress_stdout, #table_header, #table_row, #with_progress
Methods included from KnifeHelper
#chef_server_config_for, #chef_server_config_hash_for, #chef_server_names, #delete_chef_object, #knife_config, #knife_config_dir, #knife_config_file_for, #knife_data_bag_delete, #knife_download, #knife_environment_delete, #knife_upload, #local_chef_server?, #with_chef_server, #with_local_chef_server
Methods included from ProvidersHelper
#provider_availability_zones, #provider_config, #provider_credentials, #provider_for, #provider_names, #provider_names_for, #provider_regions, #provider_type, #providers_config
Methods included from ReposHelper
#find_cluster, #find_cluster_pwds, #find_cluster_pwds_with_repo, #find_cluster_with_repo, #find_data_bag, #find_data_bag_item, #find_environment, #find_repo_item, #find_role, #get_cookbook_deps, #get_cookbook_meta, #get_cookbook_versions, #get_cookbooks, #get_dirty_cookbooks, #get_entry_dependencies, #get_modified_cookbooks, #git_diff, #is_dirty?, #modified?, #repo_cfg, #repo_clusters_dir, #repo_cookbook_paths, #repo_dir, #repo_names, #repo_paths, #repos_config, #repos_dir, #run_inside_repo_dir
Methods included from FhcapHelper
Constructor Details
#initialize(options) ⇒ Checkout
Returns a new instance of Checkout.
12 13 14 15 16 17 18 |
# File 'lib/fhcap/tasks/repo/checkout.rb', line 12 def initialize() super @gitref = [:"git-ref"] @repo = [:repo] || [:name] @fallback_gitref = [:'fallback-git-ref'] @remote = [:remote] || [:'git-remote'] || find_remote(@repo) end |
Instance Attribute Details
#fallback_gitref ⇒ Object (readonly)
Returns the value of attribute fallback_gitref.
10 11 12 |
# File 'lib/fhcap/tasks/repo/checkout.rb', line 10 def fallback_gitref @fallback_gitref end |
#gitref ⇒ Object (readonly)
Returns the value of attribute gitref.
10 11 12 |
# File 'lib/fhcap/tasks/repo/checkout.rb', line 10 def gitref @gitref end |
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
10 11 12 |
# File 'lib/fhcap/tasks/repo/checkout.rb', line 10 def remote @remote end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
10 11 12 |
# File 'lib/fhcap/tasks/repo/checkout.rb', line 10 def repo @repo end |
Instance Method Details
#run ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/fhcap/tasks/repo/checkout.rb', line 20 def run thor.say "Repo::Checkout: repo = #{repo}, git-ref = #{gitref}, remote = #{remote}\n", :yellow if git_clone(repo) if gitref if clean?(repo) unless checkout_git_ref exit_with_error("Failed to checkout #{gitref} on #{repo} repo!") end else exit_with_error("You specified a git-ref option, but have uncommitted changes in your local repo (#{repo_dir(repo)}). Please commit your local changes before continuing!") end else current_ref = Dir.chdir repo_dir(repo) do [:verbose] ? `git rev-list HEAD -n 1 --pretty` : `git rev-parse HEAD` end thor.say "No git-ref option specified, using current ref: #{current_ref}" end else exit_with_error("Failed to clone #{repo}!") end end |