Class: FossilDownloadStrategy
- Inherits:
-
VCSDownloadStrategy
- Object
- AbstractDownloadStrategy
- VCSDownloadStrategy
- FossilDownloadStrategy
- Defined in:
- download_strategy/fossil_download_strategy.rb
Overview
Strategy for downloading a Fossil repository.
Constant Summary
Constants inherited from VCSDownloadStrategy
VCSDownloadStrategy::REF_TYPES
Constants inherited from AbstractDownloadStrategy
AbstractDownloadStrategy::HOMEBREW_CONTROLLED_STRATEGIES
Instance Attribute Summary
Attributes inherited from VCSDownloadStrategy
Attributes inherited from AbstractDownloadStrategy
Instance Method Summary collapse
- #initialize(url, name, version, **meta) ⇒ void constructor private
-
#last_commit ⇒ String
Return last commit's unique identifier for the repository.
- #repo_valid? ⇒ Boolean private
- #sandbox_write_path ⇒ Pathname private
-
#source_modified_time ⇒ Time
Returns the most recent modified time for all files in the current working directory after stage.
- #source_revision ⇒ String? private
Methods inherited from VCSDownloadStrategy
#command_sandbox, #commit_outdated?, #fetch, #fetch_last_commit, #fetching?, #head?
Methods inherited from AbstractDownloadStrategy
#basename, #cached_location, #chdir, #clear_cache, expand_deferred_environment_for?, #fetch, #fetched_size, #ohai, #quiet!, #quiet?, #stage, #total_size
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_once, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_cannot_install, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning
Methods included from SystemCommand::Mixin
#command_sandbox, #system_command, #system_command!
Methods included from Context
current, current=, #debug?, #deferred_environment_expansion?, #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.
11 12 13 14 15 16 |
# File 'download_strategy/fossil_download_strategy.rb', line 11 def initialize(url, name, version, **) super @url = T.let(@url.sub(%r{^fossil://}, ""), String) # Keep SQLite journals writable without granting writes to the whole cache. @cached_location = Pathname("#{cached_location}-sandbox")/"repository.fossil" end |
Instance Method Details
#last_commit ⇒ String
Return last commit's unique identifier for the repository.
40 41 42 43 44 45 46 |
# File 'download_strategy/fossil_download_strategy.rb', line 40 def last_commit out = silent_command("fossil", args: ["info", "tip", "-R", cached_location]).stdout commit = out[/^(?:hash|uuid): +(\h+) .+$/, 1] raise "Could not parse the commit hash from `fossil info tip` for #{cached_location}" if commit.nil? commit end |
#repo_valid? ⇒ 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.
49 50 51 |
# File 'download_strategy/fossil_download_strategy.rb', line 49 def repo_valid? silent_command("fossil", args: ["branch", "-R", cached_location]).success? end |
#sandbox_write_path ⇒ Pathname
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.
19 |
# File 'download_strategy/fossil_download_strategy.rb', line 19 def sandbox_write_path = cached_location.dirname |
#source_modified_time ⇒ Time
Returns the most recent modified time for all files in the current working directory after stage.
25 26 27 28 29 30 31 |
# File 'download_strategy/fossil_download_strategy.rb', line 25 def source_modified_time out = silent_command("fossil", args: ["info", "tip", "-R", cached_location]).stdout modified_time = out[/^(?:hash|uuid): +\h+ (.+)$/, 1] raise "Could not parse the modification time from `fossil info tip` for #{cached_location}" if modified_time.nil? Time.parse(modified_time) end |
#source_revision ⇒ 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.
34 |
# File 'download_strategy/fossil_download_strategy.rb', line 34 def source_revision = last_commit.presence |