Skip to content

Commit

Permalink
updating to remove regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Kerwin committed Mar 12, 2020
1 parent cdedd36 commit d220eb8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,13 @@ public class BuildFileUtility {
}

public String updateBuildScriptDependenciesToApplyFromRemote(String buildFileContents, String replacement) {
String currentContentPattern = getBuildScriptDependencyContentPattern()
int startIndex = buildFileContents.indexOf(START_BUILDSCRIPT_DEPENDENCY) - 1
int endIndex = buildFileContents.indexOf(END_BUILDSCRIPT_DEPENDENCY) + END_BUILDSCRIPT_DEPENDENCY.length()

String newContents = buildFileContents.replaceAll(currentContentPattern, replacement)
String newContents = buildFileContents[0..startIndex] + replacement + buildFileContents[endIndex..-1]
return newContents
}

public String getBuildScriptDependencyContentPattern() {
return "${START_BUILDSCRIPT_DEPENDENCY}(.*\\n.*)+${END_BUILDSCRIPT_DEPENDENCY}"
}

public String getBuildScriptDependencyLinePattern() {
return "apply\\sfrom:\\s[\"\']?.*buildscript-dependencies.gradle[\"\']?,\\sto:\\sbuildscript"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import org.junit.jupiter.api.Test
import static org.junit.jupiter.api.Assertions.assertEquals

class BuildFileUtilityTest {

@Test
void updateVersionContentTest() {
String buildFileContent = """
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package com.synopsys.integration.utility

import com.synopsys.integration.utility.VersionUtility
import org.junit.jupiter.api.Test

import static org.junit.jupiter.api.Assertions.assertEquals


class VersionUtilityTest {

@Test
void calculateReleaseVersionTest() {
VersionUtility versionUtility = new VersionUtility()
Expand Down Expand Up @@ -142,4 +139,5 @@ class VersionUtilityTest {
version = versionUtility.calculateNextSnapshot(version)
assertEquals('4.7.4-SNAPSHOT', version)
}

}

0 comments on commit d220eb8

Please sign in to comment.