Commit 13f5a37d authored by Fabio Pelosin's avatar Fabio Pelosin

Merge pull request #2153 from CocoaPods/trunk

Trunk
parents ac76af89 e36b343c
......@@ -14,6 +14,7 @@ group :development do
gem 'cocoapods-downloader', :git => "https://github.com/CocoaPods/cocoapods-downloader.git", :branch => 'master'
gem 'cocoapods-try', :git => 'https://github.com/CocoaPods/cocoapods-try.git', :branch => 'master'
gem 'cocoapods-plugins', :git => 'https://github.com/CocoaPods/cocoapods-plugins.git', :branch => 'master'
gem 'cocoapods-trunk', :git => 'https://github.com/CocoaPods/cocoapods-trunk.git', :branch => 'master'
gem 'rake', '~> 10.1.0' # Ruby 1.8.7
gem "mocha"
......
GIT
remote: https://github.com/CocoaPods/CLAide.git
revision: fbbb2a35e92f03ac034175daa6d8e34cd8426852
revision: fc70a4b2e6d7b436b06501c48a909c0f8a4d370e
branch: master
specs:
claide (0.5.0)
GIT
remote: https://github.com/CocoaPods/Core.git
revision: fa565c17339bf624dc309e6d8cd81894f3865868
revision: 15a071e1be2cf9ba0f56ab3fe1dc8ac14f6bd9ec
branch: master
specs:
cocoapods-core (0.32.1)
......@@ -18,7 +18,7 @@ GIT
GIT
remote: https://github.com/CocoaPods/Xcodeproj.git
revision: 1f41acdf579b347e5dfb4de709900354aac20980
revision: 14799a979aa0bfb958497c5571234ada8462bff1
branch: master
specs:
xcodeproj (0.16.1)
......@@ -27,22 +27,32 @@ GIT
GIT
remote: https://github.com/CocoaPods/cocoapods-downloader.git
revision: 224c8a191ef6b98d538d6228b0549d05194944ee
revision: a1a2eeab728b931cbbba112840e5d570b97543d2
branch: master
specs:
cocoapods-downloader (0.5.0)
GIT
remote: https://github.com/CocoaPods/cocoapods-plugins.git
revision: ce2d30ff9bd4570708e51a2bdac4d8de60fe9bfc
revision: 413e7ba6c956f798af05db4aa66941c010a1517b
branch: master
specs:
cocoapods-plugins (0.1.1)
nap
GIT
remote: https://github.com/CocoaPods/cocoapods-trunk.git
revision: d53eebda39d05bd08fdba5bb2c568b535d3cec4e
branch: master
specs:
cocoapods-trunk (0.0.1)
json (~> 1.8)
nap (>= 0.6)
netrc
GIT
remote: https://github.com/CocoaPods/cocoapods-try.git
revision: 0dff2c697f487bf1b3b3ecf21deefa99020b948e
revision: bd65e634ffe50e37b549ce0a386ff0628289c7ed
branch: master
specs:
cocoapods-try (0.2.0)
......@@ -62,6 +72,7 @@ PATH
cocoapods-core (= 0.32.1)
cocoapods-downloader (~> 0.5.0)
cocoapods-plugins (~> 0.1.0)
cocoapods-trunk (~> 0.0.1)
cocoapods-try (~> 0.2.0)
colored (~> 1.2)
escape (~> 0.0.4)
......@@ -97,6 +108,7 @@ GEM
github-markup (1.2.1)
posix-spawn (~> 0.3.8)
i18n (0.6.4)
json (1.8.1)
json_pure (1.8.1)
kicker (3.0.0)
listen (~> 1.3.0)
......@@ -114,6 +126,7 @@ GEM
mocha (>= 0.13.0)
multi_json (1.9.2)
nap (0.7.0)
netrc (0.7.7)
notify (0.5.2)
open4 (1.3.3)
posix-spawn (0.3.8)
......@@ -163,6 +176,7 @@ DEPENDENCIES
cocoapods-core!
cocoapods-downloader!
cocoapods-plugins!
cocoapods-trunk!
cocoapods-try!
coveralls
diffy
......
......@@ -171,7 +171,7 @@ begin
task :rebuild_integration_fixtures do
title 'Running Integration tests'
sh 'rm -rf spec/cocoapods-integration-specs/tmp'
Rake::Task['spec:integration'].invoke
puts `bundle exec bacon spec/integration.rb`
title 'Storing fixtures'
# Copy the files to the files produced by the specs to the after folders
......
......@@ -33,6 +33,7 @@ s.files = Dir["lib/**/*.rb"] + %w{ bin/pod bin/sandbox-pod README.md LICENSE CHA
s.add_runtime_dependency 'cocoapods-downloader', '~> 0.5.0'
s.add_runtime_dependency 'cocoapods-plugins', '~> 0.1.0'
s.add_runtime_dependency 'cocoapods-try', '~> 0.2.0'
s.add_runtime_dependency 'cocoapods-trunk', '~> 0.0.1'
s.add_runtime_dependency 'colored', '~> 1.2'
s.add_runtime_dependency 'escape', '~> 0.0.4'
......
......@@ -14,13 +14,15 @@ module Pod
require 'cocoapods/command/list'
require 'cocoapods/command/outdated'
require 'cocoapods/command/project'
require 'cocoapods/command/push'
require 'cocoapods/command/repo'
require 'cocoapods/command/search'
require 'cocoapods/command/setup'
require 'cocoapods/command/spec'
require 'cocoapods/command/init'
# TODO: remove
require 'cocoapods/command/push'
self.abstract_command = true
self.command = 'pod'
self.version = VERSION
......
require 'fileutils'
require 'active_support/core_ext/string/inflections'
module Pod
class Command
class Push < Command
self.summary = 'Push new specifications to a spec-repo'
self.description = <<-DESC
Validates NAME.podspec or `*.podspec' in the current working dir, creates
a directory and version folder for the pod in the local copy of
REPO (~/.cocoapods/repos/[REPO]), copies the podspec file into the version
directory, and finally it pushes REPO to its remote.
DESC
self.summary = 'Temporary alias for the `pod repo push` command'
self.arguments = [
['REPO', :required],
['NAME.podspec', :optional]
]
def self.options
[ ["--allow-warnings", "Allows pushing even if there are warnings"],
["--local-only", "Does not perform the step of pushing REPO to its remote"] ].concat(super)
end
def initialize(argv)
@allow_warnings = argv.flag?('allow-warnings')
@local_only = argv.flag?('local-only')
@repo = argv.shift_argument
if @repo.nil?
@repo = "master"
elsif @repo.end_with? ".podspec"
@podspec = @repo
@repo = "master"
else
@podspec = argv.shift_argument
end
@push_command = Repo::Push.new(argv)
super
end
def validate!
super
help! "A spec-repo name is required." unless @repo
UI.puts '[!] The `pod push` command has been moved to `pod repo push`.'.ansi.yellow
@push_command.validate!
end
def run
validate_podspec_files
check_repo_status
update_repo
add_specs_to_repo
push_repo unless @local_only
end
#-----------------------------------------------------------------------#
private
# @!group Push sub-steps
extend Executable
executable :git
# Performs a full lint against the podspecs.
#
def validate_podspec_files
UI.puts "\nValidating #{'spec'.pluralize(count)}".yellow
podspec_files.each do |podspec|
validator = Validator.new(podspec)
validator.only_errors = @allow_warnings
begin
validator.validate
rescue Exception
raise Informative, "The `#{podspec}` specification does not validate."
end
raise Informative, "The `#{podspec}` specification does not validate." unless validator.validated?
end
end
# Checks that the repo is clean.
#
# @raise If the repo is not clean.
#
# @todo Add specs for staged and unstaged files.
#
# @todo Gracefully handle the case where source is not under git
# source control.
#
# @return [void]
#
def check_repo_status
clean = Dir.chdir(repo_dir) { `git status --porcelain 2>&1` } == ''
raise Informative, "The repo `#{@repo}` is not clean" unless clean
end
# Updates the git repo against the remote.
#
# @return [void]
#
def update_repo
UI.puts "Updating the `#{@repo}' repo\n".yellow
Dir.chdir(repo_dir) { UI.puts `git pull 2>&1` }
end
# Commits the podspecs to the source, which should be a git repo.
#
# @note The pre commit hook of the repo is skipped as the podspecs have
# already been linted.
#
# @return [void]
#
def add_specs_to_repo
UI.puts "\nAdding the #{'spec'.pluralize(count)} to the `#{@repo}' repo\n".yellow
podspec_files.each do |spec_file|
spec = Pod::Specification.from_file(spec_file)
output_path = File.join(repo_dir, spec.name, spec.version.to_s)
if Pathname.new(output_path).exist?
message = "[Fix] #{spec}"
elsif Pathname.new(File.join(repo_dir, spec.name)).exist?
message = "[Update] #{spec}"
else
message = "[Add] #{spec}"
end
FileUtils.mkdir_p(output_path)
FileUtils.cp(spec_file, output_path)
Dir.chdir(repo_dir) do
# only commit if modified
if git!("status --porcelain 2>&1").include?(spec.name)
UI.puts " - #{message}"
git!("add #{spec.name}")
git!("commit --no-verify -m '#{message}'")
else
UI.puts " - [No change] #{spec}"
end
end
@push_command.run
end
end
# Pushes the git repo against the remote.
#
# @return [void]
#
def push_repo
UI.puts "\nPushing the `#{@repo}' repo\n".yellow
Dir.chdir(repo_dir) { UI.puts `git push origin master 2>&1` }
end
#-----------------------------------------------------------------------#
private
# @!group Private helpers
# @return [Pathname] The directory of the repository.
#
def repo_dir
dir = config.repos_dir + @repo
raise Informative, "`#{@repo}` repo not found" unless dir.exist?
dir
end
# @return [Array<Pathname>] The path of the specifications to push.
#
def podspec_files
files = Pathname.glob(@podspec || "*.podspec")
raise Informative, "Couldn't find any .podspec file in current directory" if files.empty?
files
end
# @return [Integer] The number of the podspec files to push.
#
def count
podspec_files.count
end
#-----------------------------------------------------------------------#
end
end
end
require 'fileutils'
require 'cocoapods/command/repo/push'
module Pod
class Command
......
require 'fileutils'
require 'active_support/core_ext/string/inflections'
module Pod
class Command
class Repo < Command
class Push < Repo
self.summary = 'Push new specifications to a spec-repo'
self.description = <<-DESC
Validates NAME.podspec or `*.podspec' in the current working dir, creates
a directory and version folder for the pod in the local copy of
REPO (~/.cocoapods/repos/[REPO]), copies the podspec file into the version
directory, and finally it pushes REPO to its remote.
DESC
self.arguments = [
['REPO', :required],
['NAME.podspec', :optional]
]
def self.options
[ ["--allow-warnings", "Allows pushing even if there are warnings"],
["--local-only", "Does not perform the step of pushing REPO to its remote"] ].concat(super)
end
def initialize(argv)
@allow_warnings = argv.flag?('allow-warnings')
@local_only = argv.flag?('local-only')
@repo = argv.shift_argument
@podspec = argv.shift_argument
super
end
def validate!
super
help! "A spec-repo name is required." unless @repo
if @repo == 'master'
help! "To push to the master repo use the `pod trunk push` command"
end
end
def run
validate_podspec_files
check_repo_status
update_repo
add_specs_to_repo
push_repo unless @local_only
end
#---------------------------------------------------------------------#
private
# @!group Push sub-steps
extend Executable
executable :git
# Performs a full lint against the podspecs.
#
def validate_podspec_files
UI.puts "\nValidating #{'spec'.pluralize(count)}".yellow
podspec_files.each do |podspec|
validator = Validator.new(podspec)
validator.only_errors = @allow_warnings
begin
validator.validate
rescue Exception
raise Informative, "The `#{podspec}` specification does not validate."
end
raise Informative, "The `#{podspec}` specification does not validate." unless validator.validated?
end
end
# Checks that the repo is clean.
#
# @raise If the repo is not clean.
#
# @todo Add specs for staged and unstaged files.
#
# @todo Gracefully handle the case where source is not under git
# source control.
#
# @return [void]
#
def check_repo_status
clean = Dir.chdir(repo_dir) { `git status --porcelain 2>&1` } == ''
raise Informative, "The repo `#{@repo}` is not clean" unless clean
end
# Updates the git repo against the remote.
#
# @return [void]
#
def update_repo
UI.puts "Updating the `#{@repo}' repo\n".yellow
Dir.chdir(repo_dir) { UI.puts `git pull 2>&1` }
end
# Commits the podspecs to the source, which should be a git repo.
#
# @note The pre commit hook of the repo is skipped as the podspecs have
# already been linted.
#
# @return [void]
#
def add_specs_to_repo
UI.puts "\nAdding the #{'spec'.pluralize(count)} to the `#{@repo}' repo\n".yellow
podspec_files.each do |spec_file|
spec = Pod::Specification.from_file(spec_file)
output_path = File.join(repo_dir, spec.name, spec.version.to_s)
if Pathname.new(output_path).exist?
message = "[Fix] #{spec}"
elsif Pathname.new(File.join(repo_dir, spec.name)).exist?
message = "[Update] #{spec}"
else
message = "[Add] #{spec}"
end
FileUtils.mkdir_p(output_path)
FileUtils.cp(spec_file, output_path)
Dir.chdir(repo_dir) do
# only commit if modified
if git!("status --porcelain 2>&1").include?(spec.name)
UI.puts " - #{message}"
git!("add #{spec.name}")
git!("commit --no-verify -m '#{message}'")
else
UI.puts " - [No change] #{spec}"
end
end
end
end
# Pushes the git repo against the remote.
#
# @return [void]
#
def push_repo
UI.puts "\nPushing the `#{@repo}' repo\n".yellow
Dir.chdir(repo_dir) { UI.puts `git push origin master 2>&1` }
end
#---------------------------------------------------------------------#
private
# @!group Private helpers
# @return [Pathname] The directory of the repository.
#
def repo_dir
dir = config.repos_dir + @repo
raise Informative, "`#{@repo}` repo not found" unless dir.exist?
dir
end
# @return [Array<Pathname>] The path of the specifications to push.
#
def podspec_files
files = Pathname.glob(@podspec || "*.podspec")
raise Informative, "Couldn't find any .podspec file in current directory" if files.empty?
files
end
# @return [Integer] The number of the podspec files to push.
#
def count
podspec_files.count
end
#---------------------------------------------------------------------#
end
end
end
end
......@@ -495,42 +495,11 @@ module Pod
#
def run_pre_install_hooks
UI.message "- Running pre install hooks" do
analysis_result.specifications.each do |spec|
executed = false
libraries_using_spec(spec).each do |lib|
lib_representation = library_rep(lib)
executed ||= run_spec_pre_install_hook(spec, lib_representation)
end
UI.message "- #{spec.name}" if executed
end
executed = run_podfile_pre_install_hook
UI.message "- Podfile" if executed
end
end
# Runs the pre install hook of the given specification with the given
# library representation.
#
# @param [Specification] spec
# The spec for which the pre install hook should be run.
#
# @param [Hooks::LibraryRepresentation] lib_representation
# The library representation to be passed as an argument to the
# hook.
#
# @raise Raises an informative if the hooks raises.
#
# @return [Bool] Whether the hook was run.
#
def run_spec_pre_install_hook(spec, lib_representation)
spec.pre_install!(pod_rep(spec.root.name), lib_representation)
rescue => e
raise Informative, "An error occurred while processing the pre-install " \
"hook of #{spec}." \
"\n\n#{e.message}\n\n#{e.backtrace * "\n"}"
end
# Runs the pre install hook of the Podfile
#
# @raise Raises an informative if the hooks raises.
......@@ -554,42 +523,11 @@ module Pod
#
def run_post_install_hooks
UI.message "- Running post install hooks" do
analysis_result.specifications.each do |spec|
executed = false
libraries_using_spec(spec).each do |lib|
lib_representation = library_rep(lib)
executed ||= run_spec_post_install_hook(spec, lib_representation)
end
UI.message "- #{spec.name}" if executed
end
executed = run_podfile_post_install_hook
UI.message "- Podfile" if executed
end
end
# Runs the post install hook of the given specification with the given
# library representation.
#
# @param [Specification] spec
# The spec for which the post install hook should be run.
#
# @param [Hooks::LibraryRepresentation] lib_representation
# The library representation to be passed as an argument to the
# hook.
#
# @raise Raises an informative if the hooks raises.
#
# @return [Bool] Whether the hook was run.
#
def run_spec_post_install_hook(spec, lib_representation)
spec.post_install!(lib_representation)
rescue => e
raise Informative, "An error occurred while processing the post-install " \
"hook of #{spec}." \
"\n\n#{e.message}\n\n#{e.backtrace * "\n"}"
end
# Runs the post install hook of the Podfile
#
# @raise Raises an informative if the hooks raises.
......
Subproject commit 367aaee9111972a40d0569155f40cf6bb63e4634
Subproject commit 4222deee201cb3e4ecdc80e3408474bb36843034
......@@ -5,8 +5,8 @@ module Pod
extend SpecHelper::Command
it "invokes the right command with --help flag" do
command = command('help', 'push')
command.send(:help_command).should.be.instance_of Pod::Command::Push
command = command('help', 'repo', 'push')
command.send(:help_command).should.be.instance_of Pod::Command::Repo::Push
lambda { command.run }.should.raise CLAide::Help
end
......
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../../../../spec_helper', __FILE__)
module Pod
describe Command::Push do
describe Command::Repo::Push do
extend SpecHelper::Command
extend SpecHelper::TemporaryRepos
......@@ -11,7 +11,7 @@ module Pod
it "complains if it can't find the repo" do
Dir.chdir(fixture('banana-lib')) do
cmd = command('push', 'missing_repo')
cmd = command('repo', 'push', 'missing_repo')
cmd.expects(:validate_podspec_files).returns(true)
e = lambda { cmd.run }.should.raise Informative
e.message.should.match(/repo not found/)
......@@ -20,7 +20,7 @@ module Pod
it "complains if it can't find a spec" do
repo_make('test_repo')
e = lambda { run_command('push', 'test_repo') }.should.raise Pod::Informative
e = lambda { run_command('repo', 'push', 'test_repo') }.should.raise Pod::Informative
e.message.should.match(/Couldn't find any .podspec/)
end
......@@ -29,7 +29,7 @@ module Pod
Dir.chdir(temporary_directory) do
spec = "Spec.new do |s|; s.name = 'Broken'; s.version = '1.0' end"
File.open('Broken.podspec', 'w') {|f| f.write(spec) }
cmd = command('push', 'test_repo')
cmd = command('repo', 'push', 'test_repo')
Validator.any_instance.stubs(:validated?).returns(false)
e = lambda { cmd.run }.should.raise Pod::Informative
......@@ -68,7 +68,7 @@ module Pod
Dir.chdir(test_repo_path) do
`touch DIRTY_FILE`
end
cmd = command('push', 'master')
cmd = command('repo', 'push', 'master')
cmd.expects(:validate_podspec_files).returns(true)
e = lambda { cmd.run }.should.raise Pod::Informative
e.message.should.match(/repo.*not clean/)
......@@ -76,8 +76,7 @@ module Pod
end
it "successfully pushes a spec" do
cmd = command('push', 'master')
cmd = command('repo', 'push', 'master')
Dir.chdir(@upstream) { `git checkout -b tmp_for_push -q` }
cmd.expects(:validate_podspec_files).returns(true)
Dir.chdir(temporary_directory) { cmd.run }
......
......@@ -360,13 +360,6 @@ describe "Integration" do
describe "Runs the Podfile callbacks" do
check "install --no-repo-update", "install_podfile_callbacks"
end
# @todo add tests for all the hooks API
#
describe "Runs the specification callbacks" do
check "install --no-repo-update", "install_spec_callbacks"
end
end
#--------------------------------------#
......
......@@ -7,7 +7,6 @@ module Pod
Command.parse(%w{ install }).should.be.instance_of Command::Install
Command.parse(%w{ list }).should.be.instance_of Command::List
Command.parse(%w{ outdated }).should.be.instance_of Command::Outdated
Command.parse(%w{ push }).should.be.instance_of Command::Push
Command.parse(%w{ repo }).should.be.instance_of Command::Repo
Command.parse(%w{ repo add }).should.be.instance_of Command::Repo::Add
Command.parse(%w{ repo lint }).should.be.instance_of Command::Repo::Lint
......
......@@ -491,9 +491,6 @@ module Pod
library_rep = stub()
@installer.expects(:installer_rep).returns(installer_rep)
@installer.expects(:pod_rep).with('JSONKit').returns(pod_rep)
@installer.expects(:library_rep).with(@aggregate_target).returns(library_rep)
@spec.expects(:pre_install!)
@installer.podfile.expects(:pre_install!).with(installer_rep)
@installer.send(:run_pre_install_hooks)
end
......@@ -503,8 +500,6 @@ module Pod
target_installer_data = stub()
@installer.expects(:installer_rep).returns(installer_rep)
@installer.expects(:library_rep).with(@aggregate_target).returns(target_installer_data)
@spec.expects(:post_install!)
@installer.podfile.expects(:post_install!).with(installer_rep)
@installer.send(:run_post_install_hooks)
end
......@@ -520,11 +515,7 @@ module Pod
@installer.stubs(:pod_targets).returns([pod_target_ios, pod_target_osx])
@installer.stubs(:installer_rep).returns(stub())
@installer.stubs(:library_rep).with(@aggregate_target).returns(target_installer_data).twice
@installer.podfile.expects(:pre_install!)
@spec.expects(:post_install!).with(target_installer_data).once
@installer.send(:run_pre_install_hooks)
@installer.send(:run_post_install_hooks)
end
......@@ -561,9 +552,7 @@ module Pod
libs = @installer.send(:libraries_using_spec, @spec)
libs.map(&:name).should == ['Pods']
end
end
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