Method: Fetchers::Git#perform_relative_path_fetch

Defined in:
lib/fetchers/git.rb

#perform_relative_path_fetch(destination_path, working_dir) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/fetchers/git.rb', line 82

def perform_relative_path_fetch(destination_path, working_dir)
  Inspec::Log.debug("Checkout of #{resolved_ref} successful. " \
                    "Moving #{@relative_path} to #{destination_path}")
  unless File.exist?("#{working_dir}/#{@relative_path}")
    # Cleanup the destination path - otherwise we'll have an empty dir
    # in the cache, which is enough to confuse the cache reader
    # This is a courtesy, assuming we're writing to the cache; if we're
    # vendoring to something more complex, don't bother.
    FileUtils.rmdir(destination_path) if Dir.empty?(destination_path)

    raise ArgumentError, "Cannot find relative path '#{@relative_path}' " \
                         "within profile in git repo specified by '#{@remote_url}'"
  end
  FileUtils.cp_r("#{working_dir}/#{@relative_path}", destination_path)
end