From b9578c99deb6dc824da16ab7bca6707a3a9ccce6 Mon Sep 17 00:00:00 2001 From: David Schlosnagle Date: Fri, 28 Oct 2022 11:59:40 -0400 Subject: [PATCH 1/9] Add 3 lines of autogenerated comments to minimize merge conflicts --- .../java/com/palantir/gradle/versions/lockstate/Line.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/palantir/gradle/versions/lockstate/Line.java b/src/main/java/com/palantir/gradle/versions/lockstate/Line.java index 60697fee..2bbaa49b 100644 --- a/src/main/java/com/palantir/gradle/versions/lockstate/Line.java +++ b/src/main/java/com/palantir/gradle/versions/lockstate/Line.java @@ -46,7 +46,10 @@ default MyModuleIdentifier identifier() { @Lazy default String stringRepresentation() { - return String.format( - "%s:%s:%s (%s constraints: %s)", group(), name(), version(), numDependents(), dependentsHash()); + return "#\n" // + + "# Three lines of non-changing comments\n" // + + "# to avoid conflicts with automated upgrades\n" // + + group() + + ':' + name() + ':' + version() + " (" + numDependents() + " constraints: " + dependentsHash() + ')'; } } From 30915ba80b76e98bf6e4b52388045760188dcda9 Mon Sep 17 00:00:00 2001 From: David Schlosnagle Date: Fri, 28 Oct 2022 14:52:50 -0400 Subject: [PATCH 2/9] Update test expectations --- .../gradle/versions/VerifyLocksTask.java | 4 +- .../gradle/versions/lockstate/Line.java | 8 +++- .../gradle/versions/lockstate/LockStates.java | 2 +- ...istentVersionsPluginIntegrationSpec.groovy | 18 ++++++++ .../VersionsLockPluginIntegrationSpec.groovy | 45 +++++++++++++++++++ 5 files changed, 72 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/palantir/gradle/versions/VerifyLocksTask.java b/src/main/java/com/palantir/gradle/versions/VerifyLocksTask.java index bbe47deb..d67146f2 100644 --- a/src/main/java/com/palantir/gradle/versions/VerifyLocksTask.java +++ b/src/main/java/com/palantir/gradle/versions/VerifyLocksTask.java @@ -107,8 +107,8 @@ private static String formatDependencyDifferences(Map Date: Fri, 28 Oct 2022 18:53:03 +0000 Subject: [PATCH 3/9] Add generated changelog entries --- changelog/@unreleased/pr-1001.v2.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog/@unreleased/pr-1001.v2.yml diff --git a/changelog/@unreleased/pr-1001.v2.yml b/changelog/@unreleased/pr-1001.v2.yml new file mode 100644 index 00000000..b1058ce8 --- /dev/null +++ b/changelog/@unreleased/pr-1001.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Add 3 lines of autogenerated comments to minimize merge conflicts + links: + - https://github.com/palantir/gradle-consistent-versions/pull/1001 From 57f3ccdab9473dabb01a9638b8591a3665472f1e Mon Sep 17 00:00:00 2001 From: David Schlosnagle Date: Mon, 31 Oct 2022 11:30:53 -0400 Subject: [PATCH 4/9] Use empty commented lines --- .../gradle/versions/lockstate/Line.java | 7 +- ...istentVersionsPluginIntegrationSpec.groovy | 24 +++---- .../VersionsLockPluginIntegrationSpec.groovy | 64 +++++++++---------- 3 files changed, 47 insertions(+), 48 deletions(-) diff --git a/src/main/java/com/palantir/gradle/versions/lockstate/Line.java b/src/main/java/com/palantir/gradle/versions/lockstate/Line.java index 88b0a2a3..b4180105 100644 --- a/src/main/java/com/palantir/gradle/versions/lockstate/Line.java +++ b/src/main/java/com/palantir/gradle/versions/lockstate/Line.java @@ -46,10 +46,9 @@ default MyModuleIdentifier identifier() { @Lazy default String stringRepresentation() { - return "#\n" // - + "# Three lines of non-changing comments\n" // - + "# to avoid conflicts with automated upgrades\n" // - + lockLine(); + // Three lines of non-changing comments + // to avoid conflicts with automated upgrades + return "#\n#\n#\n" + lockLine(); } default String lockLine() { diff --git a/src/test/groovy/com/palantir/gradle/versions/ConsistentVersionsPluginIntegrationSpec.groovy b/src/test/groovy/com/palantir/gradle/versions/ConsistentVersionsPluginIntegrationSpec.groovy index 48cf1c92..82b76842 100644 --- a/src/test/groovy/com/palantir/gradle/versions/ConsistentVersionsPluginIntegrationSpec.groovy +++ b/src/test/groovy/com/palantir/gradle/versions/ConsistentVersionsPluginIntegrationSpec.groovy @@ -248,12 +248,12 @@ class ConsistentVersionsPluginIntegrationSpec extends IntegrationSpec { def expectedLock = """\ # Run ./gradlew --write-locks to regenerate this file # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # test-alignment:module-that-should-be-aligned-up:1.1 (1 constraints: a5041a2c) # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # test-alignment:module-with-higher-version:1.1 (1 constraints: a6041b2c) """.stripIndent() file('versions.lock').text == expectedLock @@ -284,8 +284,8 @@ class ConsistentVersionsPluginIntegrationSpec extends IntegrationSpec { def expectedLock = """\ # Run ./gradlew --write-locks to regenerate this file # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # org.slf4j:slf4j-api:1.7.25 (1 constraints: 4105483b) """.stripIndent() file('versions.lock').text == expectedLock @@ -345,16 +345,16 @@ class ConsistentVersionsPluginIntegrationSpec extends IntegrationSpec { file('versions.lock').text == """\ # Run ./gradlew --write-locks to regenerate this file # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # org.slf4j:slf4j-api:1.7.25 (1 constraints: 4105483b) # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # org1:platform:1.0 (1 constraints: a5041a2c) # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # org2:platform:1.0 (1 constraints: a5041a2c) """.stripIndent() diff --git a/src/test/groovy/com/palantir/gradle/versions/VersionsLockPluginIntegrationSpec.groovy b/src/test/groovy/com/palantir/gradle/versions/VersionsLockPluginIntegrationSpec.groovy index ca8e6762..30954776 100644 --- a/src/test/groovy/com/palantir/gradle/versions/VersionsLockPluginIntegrationSpec.groovy +++ b/src/test/groovy/com/palantir/gradle/versions/VersionsLockPluginIntegrationSpec.groovy @@ -606,8 +606,8 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { file('versions.lock').readLines() == [ '# Run ./gradlew --write-locks to regenerate this file', '#', - '# Three lines of non-changing comments', - '# to avoid conflicts with automated upgrades', + '#', + '#', 'org:platform:1.0 (1 constraints: a5041a2c)', ] @@ -692,12 +692,12 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { file('versions.lock').readLines() == [ '# Run ./gradlew --write-locks to regenerate this file', '#', - '# Three lines of non-changing comments', - '# to avoid conflicts with automated upgrades', + '#', + '#', 'ch.qos.logback:logback-classic:1.2.3 (1 constraints: 0805f935)', '#', - '# Three lines of non-changing comments', - '# to avoid conflicts with automated upgrades', + '#', + '#', 'org.slf4j:slf4j-api:1.7.25 (1 constraints: 400d4d2a)', ] @@ -785,18 +785,18 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { def expected = """\ # Run ./gradlew --write-locks to regenerate this file # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # ch.qos.logback:logback-classic:1.2.3 (1 constraints: 0805f935) # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # org.slf4j:slf4j-api:1.7.25 (2 constraints: 7917e690) - + [Test dependencies] # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # org:test-dep-that-logs:1.0 (1 constraints: a5041a2c) """.stripIndent() file('versions.lock').text == expected @@ -826,22 +826,22 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { def expected = """\ # Run ./gradlew --write-locks to regenerate this file # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # ch.qos.logback:logback-classic:1.2.3 (1 constraints: 0805f935) # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # org.slf4j:slf4j-api:1.7.25 (2 constraints: 7917e690) - + [Test dependencies] # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # junit:junit:4.10 (1 constraints: d904fd30) # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # org:test-dep-that-logs:1.0 (1 constraints: a5041a2c) """.stripIndent() file('versions.lock').text == expected @@ -870,8 +870,8 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { [Test dependencies] # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # junit:junit:4.10 (1 constraints: d904fd30) """.stripIndent() file('versions.lock').text == expected @@ -903,12 +903,12 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { [Test dependencies] # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # ch.qos.logback:logback-classic:1.2.3 (1 constraints: 0805f935) # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # org.slf4j:slf4j-api:1.7.25 (1 constraints: 400d4d2a) """.stripIndent() file('versions.lock').text == expected @@ -1139,12 +1139,12 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { file('versions.lock').text == """\ # Run ./gradlew --write-locks to regenerate this file # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # ch.qos.logback:logback-classic:1.2.3 (1 constraints: 0805f935) # - # Three lines of non-changing comments - # to avoid conflicts with automated upgrades + # + # org.slf4j:slf4j-api:1.7.25 (2 constraints: 8012a437) """.stripIndent() From 97e73073220cdda133df962f9c3cfb6b04dd7053 Mon Sep 17 00:00:00 2001 From: David Schlosnagle Date: Thu, 29 Jun 2023 15:29:12 -0400 Subject: [PATCH 5/9] out with hashes, in with blank lines --- .../gradle/versions/lockstate/Line.java | 2 +- ...istentVersionsPluginIntegrationSpec.groovy | 36 ++++---- .../VersionsLockPluginIntegrationSpec.groovy | 90 +++++++++---------- 3 files changed, 64 insertions(+), 64 deletions(-) diff --git a/src/main/java/com/palantir/gradle/versions/lockstate/Line.java b/src/main/java/com/palantir/gradle/versions/lockstate/Line.java index b4180105..033c0f31 100644 --- a/src/main/java/com/palantir/gradle/versions/lockstate/Line.java +++ b/src/main/java/com/palantir/gradle/versions/lockstate/Line.java @@ -48,7 +48,7 @@ default MyModuleIdentifier identifier() { default String stringRepresentation() { // Three lines of non-changing comments // to avoid conflicts with automated upgrades - return "#\n#\n#\n" + lockLine(); + return "\n\n\n" + lockLine(); } default String lockLine() { diff --git a/src/test/groovy/com/palantir/gradle/versions/ConsistentVersionsPluginIntegrationSpec.groovy b/src/test/groovy/com/palantir/gradle/versions/ConsistentVersionsPluginIntegrationSpec.groovy index 82b76842..5304b60a 100644 --- a/src/test/groovy/com/palantir/gradle/versions/ConsistentVersionsPluginIntegrationSpec.groovy +++ b/src/test/groovy/com/palantir/gradle/versions/ConsistentVersionsPluginIntegrationSpec.groovy @@ -247,13 +247,13 @@ class ConsistentVersionsPluginIntegrationSpec extends IntegrationSpec { then: def expectedLock = """\ # Run ./gradlew --write-locks to regenerate this file - # - # - # + + + test-alignment:module-that-should-be-aligned-up:1.1 (1 constraints: a5041a2c) - # - # - # + + + test-alignment:module-with-higher-version:1.1 (1 constraints: a6041b2c) """.stripIndent() file('versions.lock').text == expectedLock @@ -283,9 +283,9 @@ class ConsistentVersionsPluginIntegrationSpec extends IntegrationSpec { then: def expectedLock = """\ # Run ./gradlew --write-locks to regenerate this file - # - # - # + + + org.slf4j:slf4j-api:1.7.25 (1 constraints: 4105483b) """.stripIndent() file('versions.lock').text == expectedLock @@ -344,17 +344,17 @@ class ConsistentVersionsPluginIntegrationSpec extends IntegrationSpec { file('versions.lock').text == """\ # Run ./gradlew --write-locks to regenerate this file - # - # - # + + + org.slf4j:slf4j-api:1.7.25 (1 constraints: 4105483b) - # - # - # + + + org1:platform:1.0 (1 constraints: a5041a2c) - # - # - # + + + org2:platform:1.0 (1 constraints: a5041a2c) """.stripIndent() diff --git a/src/test/groovy/com/palantir/gradle/versions/VersionsLockPluginIntegrationSpec.groovy b/src/test/groovy/com/palantir/gradle/versions/VersionsLockPluginIntegrationSpec.groovy index 30954776..bd47695f 100644 --- a/src/test/groovy/com/palantir/gradle/versions/VersionsLockPluginIntegrationSpec.groovy +++ b/src/test/groovy/com/palantir/gradle/versions/VersionsLockPluginIntegrationSpec.groovy @@ -605,9 +605,9 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { then: file('versions.lock').readLines() == [ '# Run ./gradlew --write-locks to regenerate this file', - '#', - '#', - '#', + '', + '', + '', 'org:platform:1.0 (1 constraints: a5041a2c)', ] @@ -691,13 +691,13 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { then: 'slf4j-api still appears in the lock file' file('versions.lock').readLines() == [ '# Run ./gradlew --write-locks to regenerate this file', - '#', - '#', - '#', + '', + '', + '', 'ch.qos.logback:logback-classic:1.2.3 (1 constraints: 0805f935)', - '#', - '#', - '#', + '', + '', + '', 'org.slf4j:slf4j-api:1.7.25 (1 constraints: 400d4d2a)', ] @@ -784,19 +784,19 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { runTasks('--write-locks') def expected = """\ # Run ./gradlew --write-locks to regenerate this file - # - # - # + + + ch.qos.logback:logback-classic:1.2.3 (1 constraints: 0805f935) - # - # - # + + + org.slf4j:slf4j-api:1.7.25 (2 constraints: 7917e690) [Test dependencies] - # - # - # + + + org:test-dep-that-logs:1.0 (1 constraints: a5041a2c) """.stripIndent() file('versions.lock').text == expected @@ -825,23 +825,23 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { runTasks('--write-locks') def expected = """\ # Run ./gradlew --write-locks to regenerate this file - # - # - # + + + ch.qos.logback:logback-classic:1.2.3 (1 constraints: 0805f935) - # - # - # + + + org.slf4j:slf4j-api:1.7.25 (2 constraints: 7917e690) [Test dependencies] - # - # - # + + + junit:junit:4.10 (1 constraints: d904fd30) - # - # - # + + + org:test-dep-that-logs:1.0 (1 constraints: a5041a2c) """.stripIndent() file('versions.lock').text == expected @@ -869,9 +869,9 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { # Run ./gradlew --write-locks to regenerate this file [Test dependencies] - # - # - # + + + junit:junit:4.10 (1 constraints: d904fd30) """.stripIndent() file('versions.lock').text == expected @@ -902,13 +902,13 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { # Run ./gradlew --write-locks to regenerate this file [Test dependencies] - # - # - # + + + ch.qos.logback:logback-classic:1.2.3 (1 constraints: 0805f935) - # - # - # + + + org.slf4j:slf4j-api:1.7.25 (1 constraints: 400d4d2a) """.stripIndent() file('versions.lock').text == expected @@ -1138,13 +1138,13 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { runTasks("--write-locks") file('versions.lock').text == """\ # Run ./gradlew --write-locks to regenerate this file - # - # - # + + + ch.qos.logback:logback-classic:1.2.3 (1 constraints: 0805f935) - # - # - # + + + org.slf4j:slf4j-api:1.7.25 (2 constraints: 8012a437) """.stripIndent() From 8f87492757caf4313afd0ad0db574a93efd92b11 Mon Sep 17 00:00:00 2001 From: David Schlosnagle Date: Thu, 29 Jun 2023 16:51:36 -0400 Subject: [PATCH 6/9] Ignore empty lines in lock file --- .../java/com/palantir/gradle/versions/ConflictSafeLockFile.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/palantir/gradle/versions/ConflictSafeLockFile.java b/src/main/java/com/palantir/gradle/versions/ConflictSafeLockFile.java index e78d8d6f..93503222 100644 --- a/src/main/java/com/palantir/gradle/versions/ConflictSafeLockFile.java +++ b/src/main/java/com/palantir/gradle/versions/ConflictSafeLockFile.java @@ -74,6 +74,7 @@ public LockState readLocks() { public Stream parseLines(Stream stringStream) { return stringStream + .filter(line -> !line.isBlank()) .map(line -> { Matcher matcher = LINE_PATTERN.matcher(line); Preconditions.checkState( From 4e22d9276a9d8f4ed5370862e8cc10244322d524 Mon Sep 17 00:00:00 2001 From: David Schlosnagle Date: Thu, 29 Jun 2023 17:13:25 -0400 Subject: [PATCH 7/9] Ignore blank lines --- README.md | 2 +- .../gradle/versions/ConflictSafeLockFile.java | 11 +++++------ ...onsistentVersionsPluginIntegrationSpec.groovy | 6 +++--- .../VersionsLockPluginIntegrationSpec.groovy | 16 ++++++++-------- src/test/resources/sample-versions.lock | 2 +- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 8a905ad2..7a5d35da 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Direct dependencies are specified in a top level `versions.props` file and then 4. Run **`./gradlew --write-locks`** and see your versions.lock file be automatically created. This file should be checked into your repo: ```bash - # Run ./gradlew --write-locks to regenerate this file + # Run ./gradlew --write-locks to regenerate this file. Blank lines are to minimize merge conflicts. com.squareup.okhttp3:okhttp:3.12.0 (1 constraints: 38053b3b) com.squareup.okio:okio:1.15.0 (1 constraints: 810cbb09) ``` diff --git a/src/main/java/com/palantir/gradle/versions/ConflictSafeLockFile.java b/src/main/java/com/palantir/gradle/versions/ConflictSafeLockFile.java index 93503222..0b85d0fa 100644 --- a/src/main/java/com/palantir/gradle/versions/ConflictSafeLockFile.java +++ b/src/main/java/com/palantir/gradle/versions/ConflictSafeLockFile.java @@ -35,7 +35,8 @@ import org.gradle.api.GradleException; final class ConflictSafeLockFile { - private static final String HEADER_COMMENT = "# Run ./gradlew --write-locks to regenerate this file"; + private static final String HEADER_COMMENT = + "# Run ./gradlew --write-locks to regenerate this file. Blank lines are to minimize merge conflicts."; private static final Pattern LINE_PATTERN = Pattern.compile("(?[^(:]+):(?[^(:]+):(?[^(:\\s]+)" + "\\s+\\((?\\d+) constraints: (?\\w+)\\)"); @@ -49,16 +50,14 @@ final class ConflictSafeLockFile { /** Reads and returns the {@link LockState}. */ public LockState readLocks() { - try (Stream linesStream = Files.lines(lockfile)) { + try (Stream linesStream = Files.lines(lockfile).filter(line -> !line.isBlank())) { List lines = linesStream.filter(line -> !line.trim().startsWith("#")).collect(Collectors.toList()); int testDependenciesPosition = lines.indexOf(TEST_DEPENDENCIES_MARKER); Stream productionDeps; Stream testDeps; - if (testDependenciesPosition >= 0) { - productionDeps = lines - .subList(0, testDependenciesPosition - 1) // skip blank line before marker - .stream(); + if (testDependenciesPosition >= 0 && testDependenciesPosition + 1 < lines.size()) { + productionDeps = lines.subList(0, testDependenciesPosition).stream(); testDeps = lines.subList(testDependenciesPosition + 1, lines.size()).stream(); } else { productionDeps = lines.stream().filter(line -> !line.trim().startsWith("#")); diff --git a/src/test/groovy/com/palantir/gradle/versions/ConsistentVersionsPluginIntegrationSpec.groovy b/src/test/groovy/com/palantir/gradle/versions/ConsistentVersionsPluginIntegrationSpec.groovy index 5304b60a..0eb0e9f2 100644 --- a/src/test/groovy/com/palantir/gradle/versions/ConsistentVersionsPluginIntegrationSpec.groovy +++ b/src/test/groovy/com/palantir/gradle/versions/ConsistentVersionsPluginIntegrationSpec.groovy @@ -246,7 +246,7 @@ class ConsistentVersionsPluginIntegrationSpec extends IntegrationSpec { then: def expectedLock = """\ - # Run ./gradlew --write-locks to regenerate this file + # Run ./gradlew --write-locks to regenerate this file. Blank lines are to minimize merge conflicts. @@ -282,7 +282,7 @@ class ConsistentVersionsPluginIntegrationSpec extends IntegrationSpec { then: def expectedLock = """\ - # Run ./gradlew --write-locks to regenerate this file + # Run ./gradlew --write-locks to regenerate this file. Blank lines are to minimize merge conflicts. @@ -343,7 +343,7 @@ class ConsistentVersionsPluginIntegrationSpec extends IntegrationSpec { runTasks('--write-locks') file('versions.lock').text == """\ - # Run ./gradlew --write-locks to regenerate this file + # Run ./gradlew --write-locks to regenerate this file. Blank lines are to minimize merge conflicts. diff --git a/src/test/groovy/com/palantir/gradle/versions/VersionsLockPluginIntegrationSpec.groovy b/src/test/groovy/com/palantir/gradle/versions/VersionsLockPluginIntegrationSpec.groovy index bd47695f..323f8da6 100644 --- a/src/test/groovy/com/palantir/gradle/versions/VersionsLockPluginIntegrationSpec.groovy +++ b/src/test/groovy/com/palantir/gradle/versions/VersionsLockPluginIntegrationSpec.groovy @@ -604,7 +604,7 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { then: file('versions.lock').readLines() == [ - '# Run ./gradlew --write-locks to regenerate this file', + '# Run ./gradlew --write-locks to regenerate this file. Blank lines are to minimize merge conflicts.', '', '', '', @@ -690,7 +690,7 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { then: 'slf4j-api still appears in the lock file' file('versions.lock').readLines() == [ - '# Run ./gradlew --write-locks to regenerate this file', + '# Run ./gradlew --write-locks to regenerate this file. Blank lines are to minimize merge conflicts.', '', '', '', @@ -783,7 +783,7 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { expect: runTasks('--write-locks') def expected = """\ - # Run ./gradlew --write-locks to regenerate this file + # Run ./gradlew --write-locks to regenerate this file. Blank lines are to minimize merge conflicts. @@ -824,7 +824,7 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { expect: runTasks('--write-locks') def expected = """\ - # Run ./gradlew --write-locks to regenerate this file + # Run ./gradlew --write-locks to regenerate this file. Blank lines are to minimize merge conflicts. @@ -866,7 +866,7 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { expect: runTasks('--write-locks') def expected = """\ - # Run ./gradlew --write-locks to regenerate this file + # Run ./gradlew --write-locks to regenerate this file. Blank lines are to minimize merge conflicts. [Test dependencies] @@ -899,7 +899,7 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { expect: runTasks('--write-locks') def expected = """\ - # Run ./gradlew --write-locks to regenerate this file + # Run ./gradlew --write-locks to regenerate this file. Blank lines are to minimize merge conflicts. [Test dependencies] @@ -1137,7 +1137,7 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { expect: runTasks("--write-locks") file('versions.lock').text == """\ - # Run ./gradlew --write-locks to regenerate this file + # Run ./gradlew --write-locks to regenerate this file. Blank lines are to minimize merge conflicts. @@ -1163,7 +1163,7 @@ class VersionsLockPluginIntegrationSpec extends IntegrationSpec { """.stripIndent() def lockFileContent = """\ - # Run ./gradlew --write-locks to regenerate this file + # Run ./gradlew --write-locks to regenerate this file. Blank lines are to minimize merge conflicts. """.stripIndent() file('versions.lock').text = lockFileContent diff --git a/src/test/resources/sample-versions.lock b/src/test/resources/sample-versions.lock index 4b20493d..4e2d9210 100644 --- a/src/test/resources/sample-versions.lock +++ b/src/test/resources/sample-versions.lock @@ -1,4 +1,4 @@ -# Run ./gradlew --write-locks to regenerate this file +# Run ./gradlew --write-locks to regenerate this file. Blank lines are to minimize merge conflicts. aopalliance:aopalliance:1.0 (1 constraints: 170a83ac) ch.qos.logback:logback-access:1.2.3 (3 constraints: 4f354f15) ch.qos.logback:logback-classic:1.2.3 (5 constraints: 9351d6aa) From 147d5828aa1bf9c6dd1963c03c5cc604f765d59e Mon Sep 17 00:00:00 2001 From: David Schlosnagle Date: Thu, 29 Jun 2023 19:13:12 -0400 Subject: [PATCH 8/9] comment --- src/main/java/com/palantir/gradle/versions/lockstate/Line.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/palantir/gradle/versions/lockstate/Line.java b/src/main/java/com/palantir/gradle/versions/lockstate/Line.java index 033c0f31..609471e8 100644 --- a/src/main/java/com/palantir/gradle/versions/lockstate/Line.java +++ b/src/main/java/com/palantir/gradle/versions/lockstate/Line.java @@ -46,8 +46,7 @@ default MyModuleIdentifier identifier() { @Lazy default String stringRepresentation() { - // Three lines of non-changing comments - // to avoid conflicts with automated upgrades + // Three blank lines to avoid conflicts with automated upgrades return "\n\n\n" + lockLine(); } From a04d76c580999043083460db73d7ea699a358ccd Mon Sep 17 00:00:00 2001 From: David Schlosnagle Date: Thu, 29 Jun 2023 19:39:11 -0400 Subject: [PATCH 9/9] Update pr-1001.v2.yml --- changelog/@unreleased/pr-1001.v2.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/@unreleased/pr-1001.v2.yml b/changelog/@unreleased/pr-1001.v2.yml index b1058ce8..44fd1f07 100644 --- a/changelog/@unreleased/pr-1001.v2.yml +++ b/changelog/@unreleased/pr-1001.v2.yml @@ -1,5 +1,5 @@ type: improvement improvement: - description: Add 3 lines of autogenerated comments to minimize merge conflicts + description: Add 3 blank lines between lock entries to minimize merge conflicts links: - https://github.com/palantir/gradle-consistent-versions/pull/1001