Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix missing spec repos #749

Merged
merged 3 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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