From 9e11ec3e917dc563d3d7f9f8b0876147b56de19a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 12 May 2023 13:33:13 +0200 Subject: [PATCH 1/2] Revert "fix(gradle): update dependencies only if both group and artifact ids are the same (#7145)" This reverts commit 6252098c225778707f257ce77a6bcdd3be03b8c4. --- gradle/lib/dependabot/gradle/file_updater.rb | 24 ++------ .../dependabot/gradle/file_updater_spec.rb | 56 ------------------- ...d_same_groupId_different_artifactId.gradle | 18 ------ 3 files changed, 6 insertions(+), 92 deletions(-) delete mode 100644 gradle/spec/fixtures/buildfiles/build_same_groupId_different_artifactId.gradle diff --git a/gradle/lib/dependabot/gradle/file_updater.rb b/gradle/lib/dependabot/gradle/file_updater.rb index 13974918e23..cf8053bfb43 100644 --- a/gradle/lib/dependabot/gradle/file_updater.rb +++ b/gradle/lib/dependabot/gradle/file_updater.rb @@ -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)) diff --git a/gradle/spec/dependabot/gradle/file_updater_spec.rb b/gradle/spec/dependabot/gradle/file_updater_spec.rb index 3e6f6bc0c67..17f85e83b1e 100644 --- a/gradle/spec/dependabot/gradle/file_updater_spec.rb +++ b/gradle/spec/dependabot/gradle/file_updater_spec.rb @@ -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 diff --git a/gradle/spec/fixtures/buildfiles/build_same_groupId_different_artifactId.gradle b/gradle/spec/fixtures/buildfiles/build_same_groupId_different_artifactId.gradle deleted file mode 100644 index 826c16d346d..00000000000 --- a/gradle/spec/fixtures/buildfiles/build_same_groupId_different_artifactId.gradle +++ /dev/null @@ -1,18 +0,0 @@ -# See https://github.com/dependabot/dependabot-core/issues/7002 - -dependencies { -implementation 'com.graphql-java:graphql-java-extended-scalars:20.0' -implementation 'com.graphql-java:graphql-java:20.0' -implementation group: 'com.graphql-java', name: 'graphql-java-extended-scalars', version: '20.0' - -implementation group: 'com.graphql-java', name: 'graphql-java', version: '20.0' -implementation group: 'com.graphql-java', version: '20.0', name: 'graphql-java' - -implementation version: '20.0', group: 'com.graphql-java', name: 'graphql-java' -implementation version: '20.0', name: 'graphql-java', group: 'com.graphql-java' - -implementation name: 'graphql-java', version: '20.0', group: 'com.graphql-java' -implementation name: 'graphql-java', group: 'com.graphql-java',version: '20.0' - - -} From 06d0057f2879dddeb35fcd28780a5d286311dac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 12 May 2023 13:36:15 +0200 Subject: [PATCH 2/2] Add gradle version catalog smoke test --- .github/workflows/smoke.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index a9053412f7e..a0027d1bfab 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -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} @@ -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