class Minimart::Download::GitRepository
GitRepository
manages cloning, and checking out a given Git endpoint.
Attributes
location[R]
@return [String] any location that can be cloned by Git (Path, URL).
Public Class Methods
new(location)
click to toggle source
@param [String] location Any location that can be cloned by Git (Path, URL).
# File lib/minimart/download/git_repository.rb, line 13 def initialize(location) @location = location end
Public Instance Methods
fetch(commitish, &block)
click to toggle source
Fetch the given commit, branch, or tag. @param commitish The commit, branch, or tag to clone for the given location. @yield [Dir] Tmp directory containing the repository. This directory will be removed when the block exits.
# File lib/minimart/download/git_repository.rb, line 20 def fetch(commitish, &block) Dir.mktmpdir do |tmpdir| result_repo = Git.clone(bare_repo_path, tmpdir) result_repo.fetch(bare_repo_path, tags: true) result_repo.reset_hard(bare_repo.revparse(commitish)) block.call(tmpdir) if block end end
Private Instance Methods
bare_repo()
click to toggle source
# File lib/minimart/download/git_repository.rb, line 35 def bare_repo @bare_repo ||= Download::GitCache.instance.get_repository(location) end
bare_repo_path()
click to toggle source
# File lib/minimart/download/git_repository.rb, line 31 def bare_repo_path @bare_repo_path ||= Download::GitCache.instance.local_path_for(location) end