Commit 9d87bf40 authored by Fabio Pelosin's avatar Fabio Pelosin

Merge branch 'master' into improved-search

* master:
  [#184] fix for documentation options
  [#180] check appledoc exit status
  [#112] Refactoring based on suggestions by @alloy
  [#112] Improved remote url detection for spec repo
  [#132, #183] Fix to make repo update tolerant of stray files ~./cocoapods
  [#112] Introduced --push option for setup command
parents 53b71134 18bc2ab8
......@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
"you are upgrading, first run: $ pod setup"
s.add_runtime_dependency 'xcodeproj', '~> 0.1.0'
s.add_runtime_dependency 'popen4', '~> 0.1.2'
s.add_development_dependency 'bacon', '~> 1.1'
## Make sure you can build the gem on older versions of RubyGems too:
......
......@@ -14,11 +14,7 @@ module Pod
$ pod repo update NAME
Updates the local clone of the spec-repo `NAME'. If `NAME' is omitted
this will update all spec-repos in `~/.cocoapods'.
$ pod repo set-url NAME URL
Updates the remote `URL' of the spec-repo `NAME'.}
this will update all spec-repos in `~/.cocoapods'.}
end
extend Executable
......@@ -26,7 +22,7 @@ module Pod
def initialize(argv)
case @action = argv.arguments[0]
when 'add', 'set-url'
when 'add'
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
......@@ -52,18 +48,12 @@ module Pod
end
def update
dirs = @name ? [dir] : config.repos_dir.children
dirs = @name ? [dir] : config.repos_dir.children.select {|c| c.directory?}
dirs.each do |dir|
puts "Updating spec repo `#{dir.basename}'" unless config.silent?
Dir.chdir(dir) { git("pull") }
end
end
def set_url
Dir.chdir(dir) do
git("remote set-url origin '#{@url}'")
end
end
end
end
end
......
......@@ -14,20 +14,58 @@ 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
extend Executable
executable :git
def initialize(argv)
@push_option = argv.option('--push')
super unless argv.empty?
end
def master_repo_url
def dir
config.repos_dir + 'master'
end
def read_only_url
'git://github.com/CocoaPods/Specs.git'
end
def add_master_repo_command
@command ||= Repo.new(ARGV.new(['add', 'master', master_repo_url]))
def read_write_url
'git@github.com:CocoaPods/Specs.git'
end
def url
if push?
read_write_url
else
read_only_url
end
end
def update_master_repo_remote_command
Repo.new(ARGV.new(['set-url', 'master', master_repo_url]))
def origin_url_push?
Dir.chdir(dir) do
origin_url = git('config --get remote.origin.url')
origin_url.chomp == read_write_url
end
end
def push?
@push_option || (dir.exist? && origin_url_push?)
end
def set_master_repo_url
Dir.chdir(dir) do
git("remote set-url origin '#{url}'")
end
end
def add_master_repo_command
@command ||= Repo.new(ARGV.new(['add', 'master', url]))
end
def update_master_repo_command
......@@ -35,8 +73,9 @@ module Pod
end
def run
if (config.repos_dir + 'master').exist?
update_master_repo_remote_command.run
puts "Using push access" if push? && !config.silent
if dir.exist?
set_master_repo_url
update_master_repo_command.run
else
add_master_repo_command.run
......
require 'open3'
require 'open4'
module Pod
module Generator
......@@ -15,7 +15,7 @@ module Pod
def initialize(pod)
@pod = pod
@specification = pod.specification
@target_path = pod.sandbox.root + "Documentation" + pod.name
@target_path = pod.sandbox.root + 'Documentation' + pod.name
@options = pod.specification.documentation || {}
end
......@@ -36,7 +36,7 @@ module Pod
end
def description
@specification.description || "Generated by CocoaPods."
@specification.description || 'Generated by CocoaPods.'
end
def docs_id
......@@ -49,7 +49,7 @@ module Pod
def index_file
@pod.chdir do
Dir.glob("README*", File::FNM_CASEFOLD).first
Dir.glob('README*', File::FNM_CASEFOLD).first
end
end
......@@ -76,10 +76,12 @@ module Pod
puts "[!] Skipping documentation generation because appledoc can't be found." if config.verbose?
return
end
options = generate_appledoc_options
options += ['--output', @target_path.to_s]
options += ['--keep-intermediate-files']
options += install ? ['-create-docset'] : ['--no-create-docset']
options += install ? ['--create-docset'] : ['--no-create-docset']
@target_path.mkpath
@pod.chdir do
appledoc(options)
......@@ -91,22 +93,19 @@ module Pod
arguments += options
arguments += ['--print-settings'] if config.verbose?
arguments += files.map(&:to_s)
Open3.popen3('appledoc', *arguments) do |i, o, e|
process = Open4.popen4('appledoc', *arguments) do |_, _, output, error|
if config.verbose?
puts o.read.chomp
puts e.read.chomp
else
# TODO: This is needed otherwise appledoc may not install the doc set
# This is a work around related to poor understanding of the IO class.
#
# I think we can use the non-block version here, which should read
# everything till the end and then return.
o.read
e.read
puts output.read.chomp
puts error.read.chomp
end
end
end
# appledoc exits with 1 if a warning was logged
if (process.exitstatus >= 2) && !config.silent?
puts "[!] Appledoc encountered an error. Run 'pod install --verbose' for details."
end
end
end
end
end
......@@ -6,11 +6,21 @@ describe "Pod::Command" do
it "creates the local spec-repos directory and creates a clone of the `master' repo" do
command = Pod::Command.parse('setup', '--silent')
def command.master_repo_url; SpecHelper.fixture('spec-repos/master'); end
def command.url; SpecHelper.fixture('spec-repos/master'); end
command.run
git_config('master', 'remote.origin.url').should == fixture('spec-repos/master').to_s
end
it "preserve push access for the `master' repo" do
command = Pod::Command.parse('setup', '--silent')
def command.url; SpecHelper.fixture('spec-repos/master'); end
command.run
command2 = Pod::Command.parse('setup', '--silent')
command2.url.should == 'git://github.com/CocoaPods/Specs.git'
git('master', 'remote set-url origin git@github.com:CocoaPods/Specs.git')
command2.url.should == 'git@github.com:CocoaPods/Specs.git'
end
it "adds a spec-repo" do
add_repo('private', fixture('spec-repos/master'))
git_config('private', 'remote.origin.url').should == fixture('spec-repos/master').to_s
......
......@@ -2,6 +2,7 @@ require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Command" do
it "returns the proper command class" do
config.silent.should == true
Pod::Command.parse('setup').should.be.instance_of Pod::Command::Setup
#Pod::Command.parse('spec').should.be.instance_of Pod::Command::Spec
Pod::Command.parse('repo', 'update').should.be.instance_of Pod::Command::Repo
......@@ -13,9 +14,15 @@ describe "Pod::Command::Setup" do
lambda { Pod::Command::Setup.new(argv('something')) }.should.raise Pod::Command::Help
end
it "returns the URL of the `master' spec-repo" do
it "returns the read only URL of the `master' spec-repo" do
command = Pod::Command::Setup.new(argv)
command.master_repo_url.should == 'git://github.com/CocoaPods/Specs.git'
command.url.should == 'git://github.com/CocoaPods/Specs.git'
end
it "returns the push URL of the `master' spec-repo" do
config.silent = true
command = Pod::Command::Setup.new(argv('--push'))
command.url.should == 'git@github.com:CocoaPods/Specs.git'
end
end
......
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