Class: Pod::Command::Repo::Add

Inherits:
Pod::Command::Repo show all
Defined in:
lib/cocoapods/command/repo/add.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pod::Command::Repo

#dir

Methods included from Executable

#executable, execute_command, which

Methods inherited from Pod::Command

#ensure_master_spec_repo_exists!, report_error, run

Methods included from Pod::Config::Mixin

#config

Constructor Details

#initialize(argv) ⇒ Add

Returns a new instance of Add.



24
25
26
27
28
# File 'lib/cocoapods/command/repo/add.rb', line 24

def initialize(argv)
  @shallow = argv.flag?('shallow', false)
  @name, @url, @branch = argv.shift_argument, argv.shift_argument, argv.shift_argument
  super
end

Class Method Details

.optionsObject



18
19
20
21
22
# File 'lib/cocoapods/command/repo/add.rb', line 18

def self.options
  [
    ['--shallow', 'Create a shallow clone (fast clone, but no push capabilities)'],
  ].concat(super)
end

Instance Method Details

#runObject



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/cocoapods/command/repo/add.rb', line 37

def run
  prefix = @shallow ? 'Creating shallow clone of' : 'Cloning'
  UI.section("#{prefix} spec repo `#{@name}` from `#{@url}`#{" (branch `#{@branch}`)" if @branch}") do
    config.repos_dir.mkpath
    Dir.chdir(config.repos_dir) do
      command = ['clone', @url, @name]
      command << '--depth=1' if @shallow
      git!(command)
    end
    Dir.chdir(dir) { git!('checkout', @branch) } if @branch
    SourcesManager.check_version_information(dir)
  end
end

#validate!Object



30
31
32
33
34
35
# File 'lib/cocoapods/command/repo/add.rb', line 30

def validate!
  super
  unless @name && @url
    help! 'Adding a repo needs a `NAME` and a `URL`.'
  end
end