Class: GitDownloadStrategy
- Inherits:
-
VCSDownloadStrategy
- Object
- AbstractDownloadStrategy
- VCSDownloadStrategy
- GitDownloadStrategy
- Defined in:
- download_strategy/git_download_strategy.rb
Overview
Strategy for downloading a Git repository.
Direct Known Subclasses
Constant Summary collapse
- MINIMUM_COMMIT_HASH_LENGTH =
7
Constants inherited from VCSDownloadStrategy
VCSDownloadStrategy::REF_TYPES
Instance Attribute Summary
Attributes inherited from VCSDownloadStrategy
Attributes inherited from AbstractDownloadStrategy
Instance Method Summary collapse
- #initialize(url, name, version, **meta) ⇒ void constructor private
-
#last_commit ⇒ String
Return last commit's unique identifier for the repository if fetched locally.
-
#source_modified_time ⇒ Time
Returns the most recent modified time for all files in the current working directory after stage.
- #source_revision ⇒ String? private
Methods inherited from VCSDownloadStrategy
#commit_outdated?, #fetch, #fetch_last_commit, #head?
Methods inherited from AbstractDownloadStrategy
#basename, #cached_location, #clear_cache, #fetch, #fetched_size, #ohai, #quiet!, #quiet?, #stage, #total_size
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_outdated, #pretty_uninstalled, #pretty_upgradable
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.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'download_strategy/git_download_strategy.rb', line 11 def initialize(url, name, version, **) # Needs to be before the call to `super`, as the VCSDownloadStrategy's # constructor calls `cache_tag` and sets the cache path. @only_path = [: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_commit ⇒ String
Return last commit's unique identifier for the repository if fetched locally.
42 43 44 45 46 |
# File 'download_strategy/git_download_strategy.rb', line 42 def last_commit args = ["--git-dir", git_dir, "rev-parse", "--short=#{MINIMUM_COMMIT_HASH_LENGTH}", "HEAD"] @last_commit ||= silent_command("git", args:).stdout.chomp.presence @last_commit || "" end |
#source_modified_time ⇒ Time
Returns the most recent modified time for all files in the current working directory after stage.
31 32 33 |
# File 'download_strategy/git_download_strategy.rb', line 31 def source_modified_time Time.parse(silent_command("git", args: ["--git-dir", git_dir, "show", "-s", "--format=%cD"]).stdout) end |
#source_revision ⇒ String?
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.
36 |
# File 'download_strategy/git_download_strategy.rb', line 36 def source_revision = current_revision.presence |