Class: GitHubGitDownloadStrategy
- Inherits:
-
GitDownloadStrategy
- Object
- AbstractDownloadStrategy
- VCSDownloadStrategy
- GitDownloadStrategy
- GitHubGitDownloadStrategy
- Defined in:
- download_strategy/github_git_download_strategy.rb
Overview
Strategy for downloading a Git repository from GitHub.
Constant Summary
Constants inherited from GitDownloadStrategy
GitDownloadStrategy::MINIMUM_COMMIT_HASH_LENGTH
Constants inherited from VCSDownloadStrategy
VCSDownloadStrategy::REF_TYPES
Instance Attribute Summary
Attributes inherited from VCSDownloadStrategy
Attributes inherited from AbstractDownloadStrategy
Instance Method Summary collapse
- #commit_outdated?(commit) ⇒ Boolean private
- #default_branch ⇒ String? private
- #default_refspec ⇒ String private
- #initialize(url, name, version, **meta) ⇒ void constructor private
- #last_commit ⇒ String private
Methods inherited from GitDownloadStrategy
#source_modified_time, #source_revision
Methods inherited from VCSDownloadStrategy
#fetch, #fetch_last_commit, #head?
Methods inherited from AbstractDownloadStrategy
#basename, #cached_location, #clear_cache, #fetch, #fetched_size, #ohai, #quiet!, #quiet?, #source_modified_time, #source_revision, #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.
9 10 11 12 13 14 15 16 17 18 |
# File 'download_strategy/github_git_download_strategy.rb', line 9 def initialize(url, name, version, **) super @version = version match_data = %r{^https?://github\.com/(?<user>[^/]+)/(?<repo>[^/]+)\.git$}.match(@url) return unless match_data @user = T.let(match_data[:user], T.nilable(String)) @repo = T.let(match_data[:repo], T.nilable(String)) end |
Instance Method Details
#commit_outdated?(commit) ⇒ Boolean
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.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'download_strategy/github_git_download_strategy.rb', line 28 def commit_outdated?(commit) return true unless commit return super if last_commit.blank? return true unless last_commit.start_with?(commit) if GitHub.multiple_short_commits_exist?(T.must(@user), T.must(@repo), commit) true else T.must(@version).update_commit(commit) false end end |
#default_branch ⇒ 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.
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'download_strategy/github_git_download_strategy.rb', line 51 def default_branch return @default_branch if defined?(@default_branch) command! "git", args: ["remote", "set-head", "origin", "--auto"], chdir: cached_location result = command! "git", args: ["symbolic-ref", "refs/remotes/origin/HEAD"], chdir: cached_location @default_branch = T.let(result.stdout[%r{^refs/remotes/origin/(.*)$}, 1], T.nilable(String)) end |
#default_refspec ⇒ 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.
42 43 44 45 46 47 48 |
# File 'download_strategy/github_git_download_strategy.rb', line 42 def default_refspec if default_branch "+refs/heads/#{default_branch}:refs/remotes/origin/#{default_branch}" else super end end |
#last_commit ⇒ 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.
21 22 23 24 25 |
# File 'download_strategy/github_git_download_strategy.rb', line 21 def last_commit @last_commit ||= GitHub.last_commit(T.must(@user), T.must(@repo), @ref, T.cast(T.must(version), Version), length: MINIMUM_COMMIT_HASH_LENGTH) @last_commit || super end |