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) ⇒ void constructor private
- #last_commit ⇒ String private
Methods inherited from GitDownloadStrategy
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, #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_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) ⇒ 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.
1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 |
# File 'download_strategy.rb', line 1271 def initialize(url, name, version, **) super @version = T.let(version, T.nilable(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.
1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 |
# File 'download_strategy.rb', line 1289 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?(@user, @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.
1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 |
# File 'download_strategy.rb', line 1312 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.
1303 1304 1305 1306 1307 1308 1309 |
# File 'download_strategy.rb', line 1303 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.
1283 1284 1285 1286 |
# File 'download_strategy.rb', line 1283 def last_commit @last_commit ||= GitHub.last_commit(@user, @repo, @ref, version, length: MINIMUM_COMMIT_HASH_LENGTH) @last_commit || super end |