Class: GitDownloadStrategy

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

Overview

Strategy for downloading a Git repository.

Direct Known Subclasses

GitHubGitDownloadStrategy

Constant Summary collapse

SHALLOW_CLONE_ALLOWLIST =
[
  %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, #quiet?, #shutup!, #stage

Methods included from Context

current, current=, #debug?, #quiet?, #verbose?, #with_context

Constructor Details

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

Returns a new instance of GitDownloadStrategy.


697
698
699
700
701
702
# File 'Library/Homebrew/download_strategy.rb', line 697

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

Instance Method Details

#last_commitObject


711
712
713
714
# File 'Library/Homebrew/download_strategy.rb', line 711

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

#source_modified_timeObject

Returns the most recent modified time for all files in the current working directory after stage.


705
706
707
708
# File 'Library/Homebrew/download_strategy.rb', line 705

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