Skip to content
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
5 changes: 2 additions & 3 deletions maven/lib/dependabot/maven/file_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,9 @@ def update_version_in_file(dependency, file, previous_req, requirement)
updated_content = file.content

original_file_declarations(dependency, previous_req).each do |old_dec|
updated_content = updated_content.gsub(
old_dec,
updated_content = updated_content.gsub(old_dec) do
updated_file_declaration(old_dec, previous_req, requirement)
)
end
end

raise "Expected content to change!" if updated_content == file.content
Expand Down
31 changes: 31 additions & 0 deletions maven/spec/dependabot/maven/file_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,37 @@
end
end
end

context "with double backslashes in plugin" do
let(:pom_body) { fixture("poms", "plugin_with_double_backslashes.xml") }
let(:dependencies) do
[
Dependabot::Dependency.new(
name: "com.diffplug.spotless:spotless-maven-plugin",
version: "2.27.1",
requirements: [{
file: "pom.xml",
requirement: "2.27.1",
groups: [],
source: nil,
metadata: { packaging_type: "jar" }
}],
previous_requirements: [{
file: "pom.xml",
requirement: "2.27.0",
groups: [],
source: nil,
metadata: { packaging_type: "jar" }
}],
package_manager: "maven"
)
]
end

its(:content) do
is_expected.to include("<order>java,javax,org,com,,\\\\#</order>")
end
end
end

context "the updated extensions.xml file" do
Expand Down
28 changes: 28 additions & 0 deletions maven/spec/fixtures/poms/plugin_with_double_backslashes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.dependabot</groupId>
<artifactId>basic-pom</artifactId>
<version>0.0.1-RELEASE</version>
<name>Dependabot Plugin POM</name>

<packaging>pom</packaging>

<build>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.27.0</version>
<configuration>
<java>
<importOrder>
<order>java,javax,org,com,,\\#</order>
</importOrder>
</java>
</configuration>
</plugin>
</plugins>
</build>
</project>