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

Revert "fix(gradle): update dependencies only if both group and artifact ids are the same" #7304

Merged
merged 2 commits into from
May 12, 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
7 changes: 7 additions & 0 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- { path: go_modules, name: go-security, ecosystem: gomod }
- { path: go_modules, name: go-update-pr, ecosystem: gomod }
- { path: gradle, name: gradle, ecosystem: gradle }
- { path: gradle, name: gradle-version-catalog, ecosystem: gradle }
- { path: hex, name: hex, ecosystem: mix }
- { path: maven, name: maven, ecosystem: maven }
- { path: npm_and_yarn, name: npm, ecosystem: npm}
Expand Down Expand Up @@ -125,6 +126,12 @@ jobs:
- 'common/**'
- 'updater/**'
- 'gradle/**'
'gradle-version-catalog':
- .github/workflows/smoke.yml
- Dockerfile.updater-core
- 'common/**'
- 'updater/**'
- 'gradle/**'
hex:
- .github/workflows/smoke.yml
- Dockerfile.updater-core
Expand Down
24 changes: 6 additions & 18 deletions gradle/lib/dependabot/gradle/file_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,27 +139,15 @@ def original_buildfile_declarations(dependency, requirement)
line = evaluate_properties(line, buildfile)
line = line.gsub(%r{(?<=^|\s)//.*$}, "")

line_matches_dependency?(line, dependency, requirement)
end
end

def line_matches_dependency?(line, dependency, requirement)
if dependency.name.include?(":")
group, name = dependency.name.split(":")
version = requirement.fetch(:requirement)

line.include?("#{group}:#{name}:#{version}") || (
/group\s*[=:]\s*['"]#{group}['"]/.match?(line) &&
/name\s*[=:]\s*['"]#{name}['"]/.match?(line) &&
/version\s*[=:]\s*['"]#{version}['"]/.match?(line)
)
else
if requirement.fetch(:file).end_with?(".toml")
return false unless line.include?(dependency.name)
if dependency.name.include?(":")
next false unless line.include?(dependency.name.split(":").first)
next false unless line.include?(dependency.name.split(":").last)
elsif requirement.fetch(:file).end_with?(".toml")
next false unless line.include?(dependency.name)
else
name_regex_value = /['"]#{Regexp.quote(dependency.name)}['"]/
name_regex = /(id|kotlin)(\s+#{name_regex_value}|\(#{name_regex_value}\))/
return false unless line.match?(name_regex)
next false unless line.match?(name_regex)
end

line.include?(requirement.fetch(:requirement))
Expand Down
56 changes: 0 additions & 56 deletions gradle/spec/dependabot/gradle/file_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -702,62 +702,6 @@
)
end
end
context "build_same_groupId_different_artifactId.gradle" do
let(:buildfile) do
Dependabot::DependencyFile.new(
name: "buildfiles/build_same_groupId_different_artifactId.gradle",
content: fixture("buildfiles", "build_same_groupId_different_artifactId.gradle")
)
end
let(:dependencies) do
[
Dependabot::Dependency.new(
name: "com.graphql-java:graphql-java",
version: "21",
previous_version: "20.0",
requirements: [{
file: "buildfiles/build_same_groupId_different_artifactId.gradle",
requirement: "21.0",
groups: [],
source: nil,
metadata: nil
}],
previous_requirements: [{
file: "buildfiles/build_same_groupId_different_artifactId.gradle",
requirement: "20.0",
groups: [],
source: nil,
metadata: nil
}],
package_manager: "gradle"
)
]
end

subject(:updated_buildfile) do
updated_files.find { |f| f.name == "buildfiles/build_same_groupId_different_artifactId.gradle" }
end
its(:content) do
is_expected.
to include("com.graphql-java:graphql-java-extended-scalars:20.0")
is_expected.
to include("com.graphql-java:graphql-java:21.0")
is_expected.
to include("group: 'com.graphql-java', name: 'graphql-java', version: '21.0'")
is_expected.
to include("group: 'com.graphql-java', version: '21.0', name: 'graphql-java'")
is_expected.
to include("version: '21.0', group: 'com.graphql-java', name: 'graphql-java'")
is_expected.
to include("version: '21.0', name: 'graphql-java', group: 'com.graphql-java'")
is_expected.
to include("name: 'graphql-java', version: '21.0', group: 'com.graphql-java'")
is_expected.
to include("name: 'graphql-java', group: 'com.graphql-java',version: '21.0'")
is_expected.
to include("group: 'com.graphql-java', name: 'graphql-java-extended-scalars', version: '20.0'")
end
end
end
end
end

This file was deleted.