Skip to content

Commit

Permalink
Revert "Normalize Swift package names (#7648)"
Browse files Browse the repository at this point in the history
This reverts commit 8c107a5.
  • Loading branch information
deivid-rodriguez committed Aug 3, 2023
1 parent 1df4156 commit 049bd32
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 57 deletions.
1 change: 0 additions & 1 deletion common/lib/dependabot/file_parsers/base/dependency_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ def combined_dependency(old_dep, new_dep)
version: version,
requirements: requirements,
package_manager: old_dep.package_manager,
metadata: old_dep.metadata,
subdependency_metadata: subdependency_metadata
)
end
Expand Down
2 changes: 0 additions & 2 deletions common/lib/dependabot/update_checkers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ def updated_dependency_without_unlock
previous_version: previous_version,
previous_requirements: dependency.requirements,
package_manager: dependency.package_manager,
metadata: dependency.metadata,
subdependency_metadata: dependency.subdependency_metadata
)
end
Expand All @@ -182,7 +181,6 @@ def updated_dependency_with_own_req_unlock
previous_version: previous_version,
previous_requirements: dependency.requirements,
package_manager: dependency.package_manager,
metadata: dependency.metadata,
subdependency_metadata: dependency.subdependency_metadata
)
end
Expand Down
3 changes: 1 addition & 2 deletions swift/lib/dependabot/swift/file_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def parse
name: dep.name,
version: dep.version,
package_manager: dep.package_manager,
requirements: requirements,
metadata: dep.metadata
requirements: requirements
)
else
dependency_set << dep
Expand Down
13 changes: 2 additions & 11 deletions swift/lib/dependabot/swift/file_parser/dependency_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
require "dependabot/shared_helpers"
require "dependabot/dependency"
require "json"
require "uri"

module Dependabot
module Swift
Expand Down Expand Up @@ -48,14 +47,12 @@ def subdependencies(data, level: 0)
end

def all_dependencies(data, level: 0)
identity = data["identity"]
name = data["identity"]
url = data["url"]
name = normalize(url)
version = data["version"]

source = { type: "git", url: url, ref: version, branch: nil }
metadata = { identity: identity }
args = { name: name, version: version, package_manager: "swift", requirements: [], metadata: metadata }
args = { name: name, version: version, package_manager: "swift", requirements: [] }

if level.zero?
args[:requirements] << { requirement: nil, groups: ["dependencies"], file: nil, source: source }
Expand All @@ -68,12 +65,6 @@ def all_dependencies(data, level: 0)
[dep, *subdependencies(data, level: level + 1)].compact
end

def normalize(source)
uri = URI.parse(source.downcase)

"#{uri.host}#{uri.path}".delete_prefix("www.").delete_suffix(".git")
end

attr_reader :dependency_files, :repo_contents_path, :credentials
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def updated_lockfile_content
File.write(manifest.name, manifest.content)

SharedHelpers.with_git_configured(credentials: credentials) do
try_lockfile_update(dependency.metadata[:identity])
try_lockfile_update(dependency.name)

File.read("Package.resolved")
end
Expand Down
41 changes: 13 additions & 28 deletions swift/spec/dependabot/swift/file_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,13 @@
url = expected[:url]
version = expected[:version]
name = expected[:name]
identity = expected[:identity]
source = { type: "git", url: url, ref: version, branch: nil }

dependency = dependencies[index]

expect(dependency).to be_a(Dependabot::Dependency)
expect(dependency.name).to eq(name)
expect(dependency.version).to eq(version)
expect(dependency.metadata).to eq({ identity: identity })

if expected[:requirement]
expect(dependency.requirements).to eq([
Expand Down Expand Up @@ -92,8 +90,7 @@
let(:expectations) do
[
{
identity: "reactiveswift",
name: "github.com/reactivecocoa/reactiveswift",
name: "reactiveswift",
url: "https://github.com/ReactiveCocoa/ReactiveSwift.git",
version: "7.1.0",
requirement: "= 7.1.0",
Expand All @@ -102,8 +99,7 @@
requirement_string: "exact: \"7.1.0\""
},
{
identity: "swift-docc-plugin",
name: "github.com/apple/swift-docc-plugin",
name: "swift-docc-plugin",
url: "https://github.com/apple/swift-docc-plugin",
version: "1.0.0",
requirement: ">= 1.0.0, < 2.0.0",
Expand All @@ -112,17 +108,15 @@
requirement_string: "from: \"1.0.0\""
},
{
identity: "swift-benchmark",
name: "github.com/google/swift-benchmark",
name: "swift-benchmark",
url: "https://github.com/google/swift-benchmark",
version: "0.1.1",
requirement: ">= 0.1.0, < 0.1.2",
declaration_string: ".package(url: \"https://github.com/google/swift-benchmark\", \"0.1.0\"..<\"0.1.2\")",
requirement_string: "\"0.1.0\"..<\"0.1.2\""
},
{
identity: "swift-argument-parser",
name: "github.com/apple/swift-argument-parser",
name: "swift-argument-parser",
url: "https://github.com/apple/swift-argument-parser",
version: "0.5.0",
requirement: ">= 0.4.0, <= 0.5.0",
Expand All @@ -131,8 +125,7 @@
requirement_string: "\"0.4.0\" ... \"0.5.0\""
},
{
identity: "combine-schedulers",
name: "github.com/pointfreeco/combine-schedulers",
name: "combine-schedulers",
url: "https://github.com/pointfreeco/combine-schedulers",
version: "0.10.0",
requirement: ">= 0.9.2, <= 0.10.0",
Expand All @@ -141,8 +134,7 @@
requirement_string: "\"0.9.2\"...\"0.10.0\""
},
{
identity: "xctest-dynamic-overlay",
name: "github.com/pointfreeco/xctest-dynamic-overlay",
name: "xctest-dynamic-overlay",
url: "https://github.com/pointfreeco/xctest-dynamic-overlay",
version: "0.8.5"
}
Expand All @@ -158,8 +150,7 @@
let(:expectations) do
[
{
identity: "quick",
name: "github.com/quick/quick",
name: "quick",
url: "https://github.com/Quick/Quick.git",
version: "7.0.2",
requirement: ">= 7.0.0, < 8.0.0",
Expand All @@ -168,8 +159,7 @@
requirement_string: ".upToNextMajor(from: \"7.0.0\")"
},
{
identity: "nimble",
name: "github.com/quick/nimble",
name: "nimble",
url: "https://github.com/Quick/Nimble.git",
version: "9.0.1",
requirement: ">= 9.0.0, < 9.1.0",
Expand All @@ -178,8 +168,7 @@
requirement_string: ".upToNextMinor(from: \"9.0.0\")"
},
{
identity: "swift-openapi-runtime",
name: "github.com/apple/swift-openapi-runtime",
name: "swift-openapi-runtime",
url: "https://github.com/apple/swift-openapi-runtime",
version: "0.1.5",
requirement: ">= 0.1.0, < 0.2.0",
Expand All @@ -192,8 +181,7 @@
requirement_string: ".upToNextMinor(from: \"0.1.0\")"
},
{
identity: "swift-docc-plugin",
name: "github.com/apple/swift-docc-plugin",
name: "swift-docc-plugin",
url: "https://github.com/apple/swift-docc-plugin",
version: "1.0.0",
requirement: "= 1.0.0",
Expand All @@ -202,8 +190,7 @@
requirement_string: ".exact(\"1.0.0\")"
},
{
identity: "swift-benchmark",
name: "github.com/google/swift-benchmark",
name: "swift-benchmark",
url: "https://github.com/google/swift-benchmark",
version: "0.1.1",
requirement: ">= 0.1.0, < 0.1.2",
Expand All @@ -212,14 +199,12 @@
requirement_string: "\"0.1.0\"..<\"0.1.2\""
},
{
identity: "swift-argument-parser",
name: "github.com/apple/swift-argument-parser",
name: "swift-argument-parser",
url: "https://github.com/apple/swift-argument-parser",
version: "0.5.0"
},
{
identity: "xctest-dynamic-overlay",
name: "github.com/pointfreeco/xctest-dynamic-overlay",
name: "xctest-dynamic-overlay",
url: "https://github.com/pointfreeco/xctest-dynamic-overlay",
version: "0.8.5"
}
Expand Down
10 changes: 4 additions & 6 deletions swift/spec/dependabot/swift/file_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
let(:dependencies) do
[
Dependabot::Dependency.new(
name: "github.com/reactivecocoa/reactiveswift",
name: "reactiveswift",
version: "7.1.1",
previous_version: "7.1.0",
requirements: [{
Expand Down Expand Up @@ -66,8 +66,7 @@
requirement_string: "exact: \"7.1.0\""
}
}],
package_manager: "swift",
metadata: { identity: "reactiveswift" }
package_manager: "swift"
)
]
end
Expand Down Expand Up @@ -98,7 +97,7 @@
let(:dependencies) do
[
Dependabot::Dependency.new(
name: "github.com/apple/swift-docc-plugin",
name: "swift-docc-plugin",
version: "1.1.0",
previous_version: "1.0.0",
requirements: [{
Expand Down Expand Up @@ -131,8 +130,7 @@
requirement_string: "from: \"1.0.0\""
}
}],
package_manager: "swift",
metadata: { identity: "swift-docc-plugin" }
package_manager: "swift"
)
]
end
Expand Down
12 changes: 6 additions & 6 deletions swift/spec/dependabot/swift/update_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
end

context "with an up to date dependency" do
let(:name) { "github.com/reactivecocoa/reactiveswift" }
let(:name) { "reactiveswift" }
let(:url) { "https://github.com/ReactiveCocoa/ReactiveSwift" }
let(:upload_pack_fixture) { "reactive-swift" }

Expand All @@ -80,7 +80,7 @@
end

context "with a dependency that needs only lockfile changes to get updated" do
let(:name) { "github.com/quick/quick" }
let(:name) { "quick" }
let(:url) { "https://github.com/Quick/Quick" }
let(:upload_pack_fixture) { "quick" }

Expand Down Expand Up @@ -114,7 +114,7 @@
end

context "with a dependency that needs manifest changes to get updated" do
let(:name) { "github.com/quick/nimble" }
let(:name) { "nimble" }
let(:url) { "https://github.com/Quick/Nimble" }
let(:upload_pack_fixture) { "nimble" }

Expand Down Expand Up @@ -178,7 +178,7 @@
describe "#lowest_security_fix_version" do
subject(:lowest_security_fix_version) { checker.lowest_security_fix_version }

let(:name) { "github.com/quick/nimble" }
let(:name) { "nimble" }
let(:url) { "https://github.com/Quick/Nimble" }
let(:upload_pack_fixture) { "nimble" }

Expand Down Expand Up @@ -213,7 +213,7 @@
subject(:lowest_resolvable_security_fix_version) { checker.lowest_resolvable_security_fix_version }

context "when a supported newer version is available, and resolvable" do
let(:name) { "github.com/quick/nimble" }
let(:name) { "nimble" }
let(:url) { "https://github.com/Quick/Nimble" }
let(:upload_pack_fixture) { "nimble" }

Expand Down Expand Up @@ -245,7 +245,7 @@
context "when fixed version has conflicts with the project" do
let(:project_name) { "conflicts" }

let(:name) { "github.com/vapor/vapor" }
let(:name) { "vapor" }
let(:url) { "https://github.com/vapor/vapor" }
let(:upload_pack_fixture) { "vapor" }

Expand Down

0 comments on commit 049bd32

Please sign in to comment.