Skip to content

Commit

Permalink
Merge pull request #6878 from dependabot/deivid-rodriguez/gradle-inco…
Browse files Browse the repository at this point in the history
…rrect-pr

Don't consider references to catalogs in buildfiles
  • Loading branch information
deivid-rodriguez authored Mar 22, 2023
2 parents 0c8abcb + 40114f0 commit 33e4490
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions gradle/lib/dependabot/gradle/file_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def plugin_dependencies(buildfile)
blk.lines.each do |line|
name_regex = /(id|kotlin)(\s+#{PLUGIN_ID_REGEX}|\(#{PLUGIN_ID_REGEX}\))/o
name = line.match(name_regex)&.named_captures&.fetch("id")
version_regex = /version\s+['"]?(?<version>#{VSN_PART})['"]?/o
version_regex = /version\s+(?<version>['"]?#{VSN_PART}['"]?)/o
version = format_plugin_version(line.match(version_regex)&.named_captures&.fetch("version"))
next unless name && version

Expand All @@ -238,7 +238,7 @@ def plugin_dependencies(buildfile)
end

def format_plugin_version(version)
version&.match?(/^\w+$/) ? "$#{version}" : version
quoted?(version) ? unquote(version) : "$#{version}"
end

def extra_groups(line)
Expand Down Expand Up @@ -401,6 +401,14 @@ def original_file
SUPPORTED_BUILD_FILE_NAMES.include?(f.name)
end
end

def quoted?(string)
string&.match?(/^['"].*['"]$/)
end

def unquote(string)
string[1..-2]
end
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions gradle/spec/fixtures/buildfiles/root_build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ plugins {

val helmVersion = "1.6.0"
id("org.unbroken-dome.helm") version helmVersion apply false

id("not.yet.updatable") version libs.versions.notYetUpdatable apply false
}

buildscript {
Expand Down

0 comments on commit 33e4490

Please sign in to comment.