Skip to content

Commit

Permalink
only check index once
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Kerwin committed Apr 8, 2020
1 parent c24707e commit 883847e
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ public class BuildFileUtility {

public String updateBuildScriptDependenciesToApplyFromRemote(String buildFileContents, String replacement) {
String newContents = buildFileContents
if (buildFileContents.contains(START_BUILDSCRIPT_DEPENDENCY) && buildFileContents.contains(END_BUILDSCRIPT_DEPENDENCY)) {
int startIndex = buildFileContents.indexOf(START_BUILDSCRIPT_DEPENDENCY) - 1
int endIndex = buildFileContents.indexOf(END_BUILDSCRIPT_DEPENDENCY) + END_BUILDSCRIPT_DEPENDENCY.length()

newContents = buildFileContents[0..startIndex] + replacement + buildFileContents[endIndex..-1]
int startIndex = buildFileContents.indexOf(START_BUILDSCRIPT_DEPENDENCY)
int endIndex = buildFileContents.indexOf(END_BUILDSCRIPT_DEPENDENCY)
if (startIndex > -1 && endIndex > -1) {
newContents = buildFileContents[0..startIndex - 1] + replacement + buildFileContents[endIndex + END_BUILDSCRIPT_DEPENDENCY.length()..-1]
}
return newContents
}
Expand Down

0 comments on commit 883847e

Please sign in to comment.