Permalink
Browse files

Merge branch 'pod_update' into local_source

* pod_update:
  [Install/Update] Keep track of external sources while locking Pods.
  • Loading branch information...
2 parents 8a4f5ac + 15e9f3b commit dca782c3287e514da1e0f4d024384caeacc1f245 @fabiopelosin fabiopelosin committed Aug 14, 2012
Showing with 23 additions and 21 deletions.
  1. +2 −2 lib/cocoapods/dependency.rb
  2. +13 −0 lib/cocoapods/lockfile.rb
  3. +8 −19 lib/cocoapods/resolver.rb
@@ -3,9 +3,9 @@
module Pod
class Dependency < Gem::Dependency
- attr_reader :external_source, :head
+ attr_reader :head
alias :head? :head
- attr_accessor :specification
+ attr_accessor :specification, :external_source
def initialize(*name_and_version_requirements, &block)
if name_and_version_requirements.empty? && block
View
@@ -80,6 +80,19 @@ def pods_versions
@pods_versions
end
+ # @return [Dependency] A dependency that describes the exact installed version
+ # of a Pod.
+ #
+ def dependency_for_installed_pod_named(name)
+ version = pods_versions[name]
+ raise Informative, "Attempt to lock a Pod without an known version." unless version
+ dependency = Dependency.new(name, version)
+ if external_source = external_sources[name]
+ dependency.external_source = Dependency::ExternalSources.from_params(dependency.name, external_source)
+ end
+ dependency
+ end
+
# @param [String] The string that describes a {Specification} generated
# from {Specification#to_s}.
#
View
@@ -65,7 +65,8 @@ def resolve
@cached_specs = {}
@specs_by_target = {}
@pods_from_external_sources = []
- @log_indent = 0;
+ @pods_to_lock = []
+ @log_indent = 0
if @lockfile
puts "\nFinding added, modified or removed dependencies:".green if config.verbose?
@@ -87,8 +88,7 @@ def resolve
end
end
end
- pods_not_to_lock = @pods_by_state[:added] + @pods_by_state[:changed] + @pods_by_state[:removed]
- lock_versions(lockfile.pods_names - pods_not_to_lock) unless update_mode
+ @pods_to_lock = (lockfile.pods_names - @pods_by_state[:added] - @pods_by_state[:changed] - @pods_by_state[:removed]).uniq
end
@podfile.target_definitions.values.each do |target_definition|
@@ -152,22 +152,6 @@ def removed_pods
private
- # Locks the given Pods to the version stored in the Lockfile.
- #
- # @return [void]
- #
- def lock_versions(pods)
- return unless lockfile
- # Add a specific Dependency to lock the version in the resolution process
- pods.each do |pod_name|
- version = lockfile.pods_versions[pod_name]
- raise Informative, "Attempt to lock a Pod without an known version." unless version
- dependency = Dependency.new(pod_name, version)
- set = find_cached_set(dependency, nil)
- set.required_by(dependency, lockfile.to_s)
- end
- end
-
# @return [Set] The cached set for a given dependency.
#
def find_cached_set(dependency, platform)
@@ -205,6 +189,11 @@ def find_cached_set(dependency, platform)
def find_dependency_specs(dependent_specification, dependencies, target_definition)
@log_indent += 1
dependencies.each do |dependency|
+ # Replace the dependency with a more specific one if the pod is already installed.
+ if !update_mode && @pods_to_lock.include?(dependency.name)
+ dependency = lockfile.dependency_for_installed_pod_named(dependency.name)
+ end
+
puts ' ' * @log_indent + "- #{dependency}" if config.verbose?
set = find_cached_set(dependency, target_definition.platform)
set.required_by(dependency, dependent_specification.to_s)

0 comments on commit dca782c

Please sign in to comment.