Class: VCSDownloadStrategy Abstract Private
- Inherits:
-
AbstractDownloadStrategy
- Object
- AbstractDownloadStrategy
- VCSDownloadStrategy
- Defined in:
- Library/Homebrew/download_strategy.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Abstract superclass for all download strategies downloading from a version control system.
Direct Known Subclasses
BazaarDownloadStrategy, CVSDownloadStrategy, FossilDownloadStrategy, GitDownloadStrategy, MercurialDownloadStrategy, SubversionDownloadStrategy
Constant Summary collapse
- REF_TYPES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[:tag, :branch, :revisions, :revision].freeze
Instance Attribute Summary
Attributes inherited from AbstractDownloadStrategy
#cache, #cached_location, #source_modified_time, #url
Instance Method Summary collapse
- #commit_outdated?(commit) ⇒ Boolean private
-
#fetch ⇒ Object
Download and cache the repository at AbstractDownloadStrategy#cached_location.
- #fetch_last_commit ⇒ Object private
- #head? ⇒ Boolean private
-
#initialize(url, name, version, **meta) ⇒ VCSDownloadStrategy
constructor
private
A new instance of VCSDownloadStrategy.
-
#last_commit ⇒ Object
Return last commit's unique identifier for the repository.
Methods inherited from AbstractDownloadStrategy
#basename, #clear_cache, #quiet?, #shutup!, #stage
Methods included from Context
current, current=, #debug?, #quiet?, #verbose?, #with_context
Constructor Details
#initialize(url, name, version, **meta) ⇒ VCSDownloadStrategy
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of VCSDownloadStrategy.
156 157 158 159 160 161 |
# File 'Library/Homebrew/download_strategy.rb', line 156 def initialize(url, name, version, **) super @ref_type, @ref = extract_ref() @revision = [:revision] @cached_location = @cache/"#{name}--#{cache_tag}" end |
Instance Method Details
#commit_outdated?(commit) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
197 198 199 200 |
# File 'Library/Homebrew/download_strategy.rb', line 197 def commit_outdated?(commit) @last_commit ||= fetch_last_commit commit != @last_commit end |
#fetch ⇒ Object
Download and cache the repository at AbstractDownloadStrategy#cached_location.
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'Library/Homebrew/download_strategy.rb', line 166 def fetch ohai "Cloning #{url}" if cached_location.exist? && repo_valid? puts "Updating #{cached_location}" update elsif cached_location.exist? puts "Removing invalid repository from cache" clear_cache clone_repo else clone_repo end version.update_commit(last_commit) if head? return unless @ref_type == :tag return unless @revision && current_revision return if current_revision == @revision raise <<~EOS #{@ref} tag should be #{@revision} but is actually #{current_revision} EOS end |
#fetch_last_commit ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
192 193 194 195 |
# File 'Library/Homebrew/download_strategy.rb', line 192 def fetch_last_commit fetch last_commit end |
#head? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
202 203 204 |
# File 'Library/Homebrew/download_strategy.rb', line 202 def head? version.respond_to?(:head?) && version.head? end |
#last_commit ⇒ Object
Return last commit's unique identifier for the repository. Return most recent modified timestamp unless overridden.
210 211 212 |
# File 'Library/Homebrew/download_strategy.rb', line 210 def last_commit source_modified_time.to_i.to_s end |