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, #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.


681
682
683
684
685
686
# File 'Library/Homebrew/download_strategy.rb', line 681

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

Instance Method Details

#last_commitObject


695
696
697
698
# File 'Library/Homebrew/download_strategy.rb', line 695

def last_commit
  out, = system_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.


689
690
691
692
# File 'Library/Homebrew/download_strategy.rb', line 689

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