Class: GitHubGitDownloadStrategy
- Inherits:
-
GitDownloadStrategy
- Object
- AbstractDownloadStrategy
- VCSDownloadStrategy
- GitDownloadStrategy
- GitHubGitDownloadStrategy
- Defined in:
- 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) ⇒ GitHubGitDownloadStrategy
constructor
private
A new instance of GitHubGitDownloadStrategy.
- #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
#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled
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) ⇒ GitHubGitDownloadStrategy
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.
Returns a new instance of GitHubGitDownloadStrategy.
1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 |
# File 'download_strategy.rb', line 1279 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.
1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 |
# File 'download_strategy.rb', line 1298 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.
1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 |
# File 'download_strategy.rb', line 1321 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.
1312 1313 1314 1315 1316 1317 1318 |
# File 'download_strategy.rb', line 1312 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.
1291 1292 1293 1294 1295 |
# File 'download_strategy.rb', line 1291 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 |