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 VCSDownloadStrategy
Attributes inherited from AbstractDownloadStrategy
#cache, #cached_location, #source_modified_time, #url
Instance Method Summary collapse
-
#commit_outdated?(commit) ⇒ Boolean
-
#default_branch ⇒ String?
-
#default_refspec ⇒ String
-
#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?
Methods inherited from AbstractDownloadStrategy
#basename, #clear_cache, #fetch, #quiet!, #quiet?, #shutup!, #stage
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.
1106 1107 1108 1109 1110 1111 1112 1113 1114 |
# File 'download_strategy.rb', line 1106 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
1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 |
# File 'download_strategy.rb', line 1116 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?
1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 |
# File 'download_strategy.rb', line 1143 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
1134 1135 1136 1137 1138 1139 1140 |
# File 'download_strategy.rb', line 1134 def default_refspec if default_branch "+refs/heads/#{default_branch}:refs/remotes/origin/#{default_branch}" else super end end |