Skip to content

Commit

Permalink
Merge pull request #749 from fnxpt/master-1
Browse files Browse the repository at this point in the history
Fix missing spec repos in Podfile.lock
  • Loading branch information
amorde committed Dec 24, 2023
2 parents cf9a87d + 097be75 commit ec4fbde
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/cocoapods-core/lockfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -485,17 +485,27 @@ def generate_dependencies_data(podfile)
# { "https://github.com/cocoapods/cocoapods.git" => ["Alamofire", "Moya"] }
#
def generate_spec_repos(spec_repos)
Hash[spec_repos.map do |source, specs|
output = Hash.new {|h, k| h[k] = Array.new(0)}
spec_repos.each do |source, specs|
next unless source
next if specs.empty?
key = source.url || source.name

# save `trunk` as 'trunk' so that the URL itself can be changed without lockfile churn
key = Pod::TrunkSource::TRUNK_REPO_NAME if source.name == Pod::TrunkSource::TRUNK_REPO_NAME

value = specs.map { |s| s.root.name }.uniq
[key, YAMLHelper.sorted_array(value)]
end.compact]
value = specs.map { |s| s.root.name }

if output.has_key?(key)
value = value + output[key]
end

if value.length > 0
output[key] = YAMLHelper.sorted_array(value.uniq)
end
end

output.compact
end

# Generates the information of the external sources.
Expand Down
33 changes: 33 additions & 0 deletions spec/lockfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,39 @@ def self.specs_by_source
spec_repos_data.should == { 'trunk' => %w(a b C) }
end
end

describe '#generate_spec_repos_with_duplicated_source' do
it 'merges specs if sources have same key' do
spec_repos = {
Source.new(fixture('spec-repos/trunk')) => [
Specification.new do |s|
s.name = 'a'
s.version = '1.0'
end,
Specification.new do |s|
s.name = 'b'
s.version = '1.0'
end,
Specification.new do |s|
s.name = 'C'
s.version = '1.0'
end,
],
Source.new(fixture('spec-repos/trunk')) => [
Specification.new do |s|
s.name = 'd'
s.version = '1.0'
end,
Specification.new do |s|
s.name = 'E'
s.version = '1.0'
end,
],
}
spec_repos_data = Lockfile.send(:generate_spec_repos, spec_repos)
spec_repos_data.should == { 'trunk' => %w(a b C d E) }
end
end
end
end
end

0 comments on commit ec4fbde

Please sign in to comment.