Commit 05c2c81b authored by Samuel E. Giddins's avatar Samuel E. Giddins

make concurrency possible

parent b6d4872d
......@@ -15,8 +15,8 @@ gem 'json', '1.7.7'
group :development do
cp_gem 'claide', 'CLAide'
cp_gem 'cocoapods-core', 'Core'
cp_gem 'cocoapods-downloader', 'cocoapods-downloader'
cp_gem 'cocoapods-core', 'Core', 'seg-concurrent'
cp_gem 'cocoapods-downloader', 'cocoapods-downloader', 'seg-concurrent'
cp_gem 'cocoapods-plugins', 'cocoapods-plugins'
cp_gem 'cocoapods-trunk', 'cocoapods-trunk'
cp_gem 'cocoapods-try', 'cocoapods-try'
......
......@@ -7,8 +7,8 @@ GIT
GIT
remote: https://github.com/CocoaPods/Core.git
revision: 6c4f4ea86faa3fa1fcbf7fcbb3e73e38ad5cc23c
branch: master
revision: 531d9f23bcaf2731a600767080dfefe82527994a
branch: seg-concurrent
specs:
cocoapods-core (0.36.0.rc.1)
activesupport (>= 3.2.15)
......@@ -33,8 +33,8 @@ GIT
GIT
remote: https://github.com/CocoaPods/cocoapods-downloader.git
revision: a5a642e572937eb08097fbf65b30e1e7a3c449e9
branch: master
revision: 12a653e805f1643750081a84881c7b1b554e9c23
branch: seg-concurrent
specs:
cocoapods-downloader (0.8.1)
......
......@@ -15,6 +15,7 @@ if I18n.respond_to?(:enforce_available_locales=)
end
module Pod
require 'monitor'
require 'pathname'
require 'tmpdir'
......
......@@ -21,15 +21,15 @@ module Pod
]
def initialize(argv)
@podfile_path = Pathname.pwd + 'Podfile'
@podfile_path = Pod.pwd + 'Podfile'
@project_path = argv.shift_argument
@project_paths = Pathname.pwd.children.select { |pn| pn.extname == '.xcodeproj' }
@project_paths = Pod.pwd.children.select { |pn| pn.extname == '.xcodeproj' }
super
end
def validate!
super
raise Informative, 'Existing Podfile found in directory' unless config.podfile_path_in_dir(Pathname.pwd).nil?
raise Informative, 'Existing Podfile found in directory' unless config.podfile_path_in_dir(Pod.pwd).nil?
if @project_path
help! "Xcode project at #{@project_path} does not exist" unless File.exist? @project_path
project_path = @project_path
......
......@@ -70,7 +70,7 @@ module Pod
#
def configure_template
UI.section("Configuring #{@name} template.") do
Dir.chdir(@name) do
Pod.chdir(@name) do
if File.exist?('configure')
system("./configure #{@name}")
else
......@@ -184,7 +184,7 @@ module Pod
if !@podspecs_paths.empty?
Array(@podspecs_paths)
else
podspecs = Pathname.glob(Pathname.pwd + '*.podspec{.yaml,}')
podspecs = Pathname.glob(Pod.pwd + '*.podspec{.yaml,}')
if podspecs.count.zero?
raise Informative, 'Unable to find a podspec in the working ' \
'directory'
......
......@@ -38,12 +38,12 @@ module Pod
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
Pod.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
Pod.chdir(dir) { git!("checkout #{@branch}") } if @branch
SourcesManager.check_version_information(dir)
end
end
......
......@@ -44,7 +44,7 @@ module Pod
# @return [void]
#
def print_source_at_path(path)
Dir.chdir(path) do
Pod.chdir(path) do
if SourcesManager.git_repo?(path)
remote_name = branch_remote_name(branch_name)
if remote_name
......
......@@ -61,7 +61,7 @@ module Pod
# specs to the master repo.
#
def check_if_master_repo
remotes = Dir.chdir(repo_dir) { `git remote -v 2>&1` }
remotes = Pod.chdir(repo_dir) { `git remote -v 2>&1` }
master_repo_urls = [
'git@github.com:CocoaPods/Specs.git',
'https://github.com/CocoaPods/Specs.git',
......@@ -109,7 +109,7 @@ module Pod
# @return [void]
#
def check_repo_status
clean = Dir.chdir(repo_dir) { `git status --porcelain 2>&1` } == ''
clean = Pod.chdir(repo_dir) { `git status --porcelain 2>&1` } == ''
raise Informative, "The repo `#{@repo}` at #{UI.path repo_dir} is not clean" unless clean
end
......@@ -119,7 +119,7 @@ module Pod
#
def update_repo
UI.puts "Updating the `#{@repo}' repo\n".yellow
Dir.chdir(repo_dir) { UI.puts `git pull 2>&1` }
Pod.chdir(repo_dir) { UI.puts `git pull 2>&1` }
end
# Commits the podspecs to the source, which should be a git repo.
......@@ -144,7 +144,7 @@ module Pod
FileUtils.mkdir_p(output_path)
FileUtils.cp(spec_file, output_path)
Dir.chdir(repo_dir) do
Pod.chdir(repo_dir) do
# only commit if modified
if git!('status --porcelain 2>&1').include?(spec.name)
UI.puts " - #{message}"
......@@ -163,7 +163,7 @@ module Pod
#
def push_repo
UI.puts "\nPushing the `#{@repo}' repo\n".yellow
Dir.chdir(repo_dir) { UI.puts `git push origin master 2>&1` }
Pod.chdir(repo_dir) { UI.puts `git push origin master 2>&1` }
end
#---------------------------------------------------------------------#
......
......@@ -69,7 +69,7 @@ module Pod
# @return [void]
#
def set_master_repo_url
Dir.chdir(master_repo_dir) do
Pod.chdir(master_repo_dir) do
git("remote set-url origin '#{url}'")
end
end
......@@ -100,7 +100,7 @@ module Pod
# @return [void]
#
def set_master_repo_branch
Dir.chdir(master_repo_dir) do
Pod.chdir(master_repo_dir) do
git('checkout master')
end
end
......
......@@ -35,7 +35,7 @@ module Pod
end
spec = spec_template(data)
(Pathname.pwd + "#{data[:name]}.podspec").open('w') { |f| f << spec }
(Pod.pwd + "#{data[:name]}.podspec").open('w') { |f| f << spec }
UI.puts "\nSpecification created at #{data[:name]}.podspec".green
end
......
......@@ -137,12 +137,12 @@ module Pod
# Podfile is located.
#
def installation_root
current_path = Pathname.pwd
current_path = Pod.pwd
unless @installation_root
until current_path.root?
if podfile_path_in_dir(current_path)
@installation_root = current_path
unless current_path == Pathname.pwd
unless current_path == Pod.pwd
UI.puts("[in #{current_path}]")
end
break
......@@ -150,7 +150,7 @@ module Pod
current_path = current_path.parent
end
end
@installation_root ||= Pathname.pwd
@installation_root ||= Pod.pwd
end
@installation_root
end
......
......@@ -57,6 +57,10 @@ module Pod
def ui_message(message)
UI.puts message
end
def chdir_monitor
Pod.chdir_monitor
end
end
end
end
......
......@@ -266,7 +266,7 @@ module Pod
@installed_specs = []
pods_to_install = sandbox_state.added | sandbox_state.changed
title_options = { :verbose_prefix => '-> '.green }
root_specs.sort_by(&:name).each do |spec|
WorkerPool.process(root_specs.sort_by(&:name), 4) do |spec|
if pods_to_install.include?(spec.name)
if sandbox_state.changed.include?(spec.name) && sandbox.manifest
previous = sandbox.manifest.version(spec.name)
......
......@@ -99,7 +99,7 @@ module Pod
def run_prepare_command
return unless root_spec.prepare_command
UI.section(' > Running prepare command', '', 1) do
Dir.chdir(root) do
Pod.chdir(root) do
ENV.delete('CDPATH')
prepare_command = root_spec.prepare_command.strip_heredoc.chomp
full_command = "\nset -e\n" + prepare_command
......
......@@ -211,7 +211,7 @@ module Pod
def specification(name)
if file = specification_path(name)
original_path = development_pods[name]
Dir.chdir(original_path || Dir.pwd) { Specification.from_file(file) }
Specification.from_file(file)
end
end
......@@ -262,7 +262,7 @@ module Pod
FileUtils.copy(podspec, output_path)
end
Dir.chdir(podspec.is_a?(Pathname) ? File.dirname(podspec) : Dir.pwd) do
Pod.chdir(podspec.is_a?(Pathname) ? File.dirname(podspec) : Pod.pwd) do
spec = Specification.from_file(output_path)
unless spec.name == name
......
......@@ -78,7 +78,7 @@ module Pod
relative_header_paths.map do |relative_header_path|
absolute_source = (sandbox.root + relative_header_path)
source = absolute_source.relative_path_from(namespaced_path)
Dir.chdir(namespaced_path) do
Pod.chdir(namespaced_path) do
FileUtils.ln_sf(source, relative_header_path.basename)
end
namespaced_path + relative_header_path.basename
......
......@@ -208,16 +208,14 @@ module Pod
sources.each do |source|
UI.section "Updating spec repo `#{source.name}`" do
Dir.chdir(source.repo) do
begin
output = git!('pull --ff-only')
UI.puts output if show_output && !config.verbose?
rescue Informative
UI.warn 'CocoaPods was not able to update the ' \
"`#{source.name}` repo. If this is an unexpected issue " \
'and persists you can inspect it running ' \
'`pod repo update --verbose`'
end
begin
output = git!("--git-dir=#{(source.repo + '.git').to_s.shellescape} --work-tree=#{source.repo.to_s.shellescape} pull --ff-only")
UI.puts output if show_output && !config.verbose?
rescue Informative
UI.warn 'CocoaPods was not able to update the ' \
"`#{source.name}` repo. If this is an unexpected issue " \
'and persists you can inspect it running ' \
'`pod repo update --verbose`'
end
check_version_information(source.repo)
end
......@@ -232,7 +230,7 @@ module Pod
# @return [Bool] Whether the given source is a GIT repo.
#
def git_repo?(dir)
Dir.chdir(dir) { git('rev-parse >/dev/null 2>&1') }
Pod.chdir(dir) { git('rev-parse >/dev/null 2>&1') }
$?.success?
end
......
......@@ -146,7 +146,7 @@ module Pod
def path(pathname)
if pathname
from_path = config.podfile_path.dirname if config.podfile_path
from_path ||= Pathname.pwd
from_path ||= Pod.pwd
path = Pathname(pathname).relative_path_from(from_path)
"`#{path}`"
else
......
......@@ -136,7 +136,7 @@ EOS
SourcesManager.all.map do |source|
next unless source.type == 'file system'
repo = source.repo
Dir.chdir(repo) do
Pod.chdir(repo) do
url = `git config --get remote.origin.url 2>&1`.strip
sha = `git rev-parse HEAD 2>&1`.strip
"#{repo.basename} - #{url} @ #{sha}"
......
......@@ -350,7 +350,7 @@ module Pod
UI.warn "Skipping compilation with `xcodebuild' because it can't be found.\n".yellow
else
UI.message "\nBuilding with xcodebuild.\n".yellow do
output = Dir.chdir(config.sandbox_root) { xcodebuild }
output = Pod.chdir(config.sandbox_root) { xcodebuild }
UI.puts output
parsed_output = parse_xcodebuild_output(output)
parsed_output.each do |message|
......
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