Commit 613db0bc authored by Fabio Pelosin's avatar Fabio Pelosin

Merge branch 'setup-push'

* setup-push:
  [#112] Introduced --push option for setup command
parents 194de448 a4036386
......@@ -8,6 +8,8 @@ module Pod
autoload :Setup, 'cocoapods/command/setup'
autoload :Spec, 'cocoapods/command/spec'
attr_accessor :output
class Help < Informative
def initialize(command_class, argv)
@command_class, @argv = command_class, argv
......
......@@ -30,7 +30,7 @@ module Pod
unless (@name = argv.arguments[1]) && (@url = argv.arguments[2])
raise Informative, "#{@action == 'add' ? 'Adding' : 'Updating the remote of'} a repo needs a `name' and a `url'."
end
when 'update'
when 'update', 'read-url'
@name = argv.arguments[1]
else
super
......@@ -64,6 +64,13 @@ module Pod
git("remote set-url origin '#{@url}'")
end
end
def read_url
Dir.chdir(dir) do
@output = git("remote -v")
end
end
end
end
end
......
......@@ -14,20 +14,52 @@ module Pod
If the clone already exists, it will ensure that it is up-to-date.}
end
def self.options
" --push Use this option to enable push access once granted\n" +
super
end
def initialize(argv)
@push_access = argv.option('--push') || already_push?
puts "Setup with push access" if @push_access && !config.silent
super unless argv.empty?
end
def already_push?
if master_repo_exists?
read_master_repo_remote_command.run
read_master_repo_remote_command.output.include? master_repo_url_with_push
else
false
end
end
def master_repo_exists?
(config.repos_dir + 'master').exist?
end
def master_repo_url
'git://github.com/CocoaPods/Specs.git'
end
def master_repo_url_with_push
'git@github.com:CocoaPods/Specs.git'
end
def repo_url
@push_access ? master_repo_url_with_push : master_repo_url
end
def add_master_repo_command
@command ||= Repo.new(ARGV.new(['add', 'master', master_repo_url]))
@command ||= Repo.new(ARGV.new(['add', 'master', repo_url]))
end
def read_master_repo_remote_command
@read_command ||= Repo.new(ARGV.new(['read-url', 'master']))
end
def update_master_repo_remote_command
Repo.new(ARGV.new(['set-url', 'master', master_repo_url]))
Repo.new(ARGV.new(['set-url', 'master', repo_url]))
end
def update_master_repo_command
......@@ -35,7 +67,7 @@ module Pod
end
def run
if (config.repos_dir + 'master').exist?
if master_repo_exists?
update_master_repo_remote_command.run
update_master_repo_command.run
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment