Class: GitDownloadStrategy

Inherits:
VCSDownloadStrategy show all
Defined in:
download_strategy.rb

Overview

Strategy for downloading a Git repository.

Direct Known Subclasses

GitHubGitDownloadStrategy

Constant Summary

Constants inherited from VCSDownloadStrategy

VCSDownloadStrategy::REF_TYPES

Instance Attribute Summary

Attributes inherited from VCSDownloadStrategy

#cached_location

Attributes inherited from AbstractDownloadStrategy

#cache, #url

Instance Method Summary collapse

Methods inherited from VCSDownloadStrategy

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

Methods inherited from AbstractDownloadStrategy

#basename, #cached_location, #clear_cache, #fetch, #quiet!, #quiet?, #stage

Methods included from SystemCommand::Mixin

#system_command, #system_command!

Methods included from Context

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

Constructor Details

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

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:



949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
# File 'download_strategy.rb', line 949

def initialize(url, name, version, **meta)
  # Needs to be before the call to `super`, as the VCSDownloadStrategy's
  # constructor calls `cache_tag` and sets the cache path.
  @only_path = meta[:only_path]

  if @only_path.present?
    # "Cone" mode of sparse checkout requires patterns to be directories
    @only_path = T.let("/#{@only_path}", String) unless @only_path.start_with?("/")
    @only_path = T.let("#{@only_path}/", String) unless @only_path.end_with?("/")
  end

  super
  @ref_type ||= T.let(:branch, T.nilable(Symbol))
  @ref ||= T.let("master", T.untyped)
end

Instance Method Details

#last_commitString

Return last commit's unique identifier for the repository.

Returns:



977
978
979
# File 'download_strategy.rb', line 977

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

#source_modified_timeTime

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

Returns:



969
970
971
# File 'download_strategy.rb', line 969

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