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 VCSDownloadStrategy
VCSDownloadStrategy::REF_TYPES
Instance Attribute Summary
Attributes inherited from AbstractDownloadStrategy
#cache, #cached_location, #url
Instance Method Summary collapse
- #commit_outdated?(commit) ⇒ Boolean
- #default_branch ⇒ String? private
- #default_refspec ⇒ String private
-
#initialize(url, name, version, **meta) ⇒ GitHubGitDownloadStrategy
constructor
A new instance of GitHubGitDownloadStrategy.
Methods inherited from GitDownloadStrategy
#last_commit, #source_modified_time
Methods inherited from VCSDownloadStrategy
#fetch, #fetch_last_commit, #head?, #last_commit
Methods inherited from AbstractDownloadStrategy
#basename, #clear_cache, #fetch, #quiet!, #quiet?, #source_modified_time, #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) ⇒ GitHubGitDownloadStrategy
Returns a new instance of GitHubGitDownloadStrategy.
1114 1115 1116 1117 1118 1119 1120 1121 1122 |
# File 'download_strategy.rb', line 1114 def initialize(url, name, version, **) super match_data = %r{^https?://github\.com/(?<user>[^/]+)/(?<repo>[^/]+)\.git$}.match(@url) return unless match_data @user = match_data[:user] @repo = match_data[:repo] end |
Instance Method Details
#commit_outdated?(commit) ⇒ Boolean
1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 |
# File 'download_strategy.rb', line 1124 def commit_outdated?(commit) @last_commit ||= GitHub.last_commit(@user, @repo, @ref, version) if @last_commit return true unless commit return true unless @last_commit.start_with?(commit) if GitHub.multiple_short_commits_exist?(@user, @repo, commit) true else version.update_commit(commit) false end else super 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.
1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 |
# File 'download_strategy.rb', line 1151 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 = result.stdout[%r{^refs/remotes/origin/(.*)$}, 1] 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.
1142 1143 1144 1145 1146 1147 1148 |
# File 'download_strategy.rb', line 1142 def default_refspec if default_branch "+refs/heads/#{default_branch}:refs/remotes/origin/#{default_branch}" else super end end |