From 7a86de32e8a35f779d038cf8af2deb6ffc2fa23a Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Thu, 14 Sep 2023 14:17:10 +0200 Subject: [PATCH] Write an explicit line ending to the lockfile (#19519) Otherwise, we get the following change on Linux after generating the lockfile on Windows. ``` --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -4098,4 +4098,4 @@ } } } -} +} \ No newline at end of file ``` RELNOTES: None PiperOrigin-RevId: 565042838 Change-Id: I5b93d155d7f1baf3a11b5d5aaf199e67b99af973 --- .../build/lib/bazel/bzlmod/BazelLockFileModule.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelLockFileModule.java b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelLockFileModule.java index 08f06a886025be..27113bc8dfc5d2 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelLockFileModule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/bzlmod/BazelLockFileModule.java @@ -187,11 +187,12 @@ public static void updateLockfile(RootedPath lockfilePath, BazelLockFileValue up lockfilePath.asPath(), UTF_8, GsonTypeAdapterUtil.createLockFileGson( - lockfilePath - .asPath() - .getParentDirectory() - .getRelative(LabelConstants.MODULE_DOT_BAZEL_FILE_NAME)) - .toJson(updatedLockfile)); + lockfilePath + .asPath() + .getParentDirectory() + .getRelative(LabelConstants.MODULE_DOT_BAZEL_FILE_NAME)) + .toJson(updatedLockfile) + + "\n"); } catch (IOException e) { logger.atSevere().withCause(e).log( "Error while updating MODULE.bazel.lock file: %s", e.getMessage());