Class: Pod::Downloader::Git

Inherits:
Base
  • Object
show all
Defined in:
lib/cocoapods-downloader/git.rb

Overview

Concreted Downloader class that provides support for specifications with git sources.

Instance Attribute Summary

Attributes inherited from Base

#options, #target_path, #url

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#download, #download_head, executable, #head_supported?, #initialize, #name, user_agent_string

Methods included from APIExposable

#expose_api

Constructor Details

This class inherits a constructor from Pod::Downloader::Base

Class Method Details

.optionsObject



7
8
9
# File 'lib/cocoapods-downloader/git.rb', line 7

def self.options
  [:commit, :tag, :branch, :submodules]
end

.preprocess_options(options) ⇒ Object

Raises:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cocoapods-downloader/git.rb', line 23

def self.preprocess_options(options)
  return options unless options[:branch]

  input = [options[:git], options[:commit]].map(&:to_s)
  invalid = input.compact.any? { |value| value.start_with?('--') || value.include?(' --') }
  raise DownloaderError, "Provided unsafe input for git #{options}." if invalid

  command = ['ls-remote',
             '--',
             options[:git],
             options[:branch]]

  output = Git.execute_command('git', command)
  match = commit_from_ls_remote output, options[:branch]

  return options if match.nil?

  options[:commit] = match
  options.delete(:branch)

  options
end

Instance Method Details

#checkout_optionsObject



15
16
17
18
19
20
21
# File 'lib/cocoapods-downloader/git.rb', line 15

def checkout_options
  options = {}
  options[:git] = url
  options[:commit] = target_git('rev-parse', 'HEAD').chomp
  options[:submodules] = true if self.options[:submodules]
  options
end

#options_specific?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/cocoapods-downloader/git.rb', line 11

def options_specific?
  !(options[:commit] || options[:tag]).nil?
end