Class: GitDownloadStrategy

Inherits:
VCSDownloadStrategy show all
Defined in:
brew/Library/Homebrew/download_strategy.rb

Direct Known Subclasses

GitHubGitDownloadStrategy

Constant Summary collapse

SHALLOW_CLONE_WHITELIST =
[
  %r{git://},
  %r{https://github\.com},
  %r{http://git\.sv\.gnu\.org},
  %r{http://llvm\.org},
].freeze

Constants inherited from VCSDownloadStrategy

VCSDownloadStrategy::REF_TYPES

Instance Attribute Summary

Attributes inherited from AbstractDownloadStrategy

#cache, #cached_location, #url

Instance Method Summary collapse

Methods inherited from VCSDownloadStrategy

#commit_outdated?, #fetch, #fetch_last_commit, #head?

Methods inherited from AbstractDownloadStrategy

#basename, #clear_cache, #fetch, #ohai, #puts, #shutup!, #stage

Constructor Details

#initialize(url, name, version, **meta) ⇒ GitDownloadStrategy

Returns a new instance of GitDownloadStrategy



608
609
610
611
612
613
# File 'brew/Library/Homebrew/download_strategy.rb', line 608

def initialize(url, name, version, **meta)
  super
  @ref_type ||= :branch
  @ref ||= "master"
  @shallow = meta.fetch(:shallow) { true }
end

Instance Method Details

#last_commitObject



620
621
622
623
# File 'brew/Library/Homebrew/download_strategy.rb', line 620

def last_commit
  out, = system_command("git", args: ["--git-dir", git_dir, "rev-parse", "--short=7", "HEAD"])
  out.chomp
end

#source_modified_timeObject



615
616
617
618
# File 'brew/Library/Homebrew/download_strategy.rb', line 615

def source_modified_time
  out, = system_command("git", args: ["--git-dir", git_dir, "show", "-s", "--format=%cD"])
  Time.parse(out)
end