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