aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2023-10-30 17:03:06 +0100
committerlunaphied <lunaphied@lunaphied.me>2024-03-25 15:30:36 +0000
commitaa7653608d4d0028bb98af491aec76b2fea7f882 (patch)
tree753370dc6745147c465bc7f991d1977668f8b084 /src
parentb525d0f20c4fd94b89d6d34d8acd0ca4c579a5fc (diff)
Minor cleanup in libexpr/flake/flake.cc
(cherry picked from commit 05316d401fa509557c71140e17bb19814412fcb8) Change-Id: I6ba0b55709f5fe21beb4e9f3bf72ee28715d15f3
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/flake/flake.cc19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc
index 20d7878e9..d96f2b22e 100644
--- a/src/libexpr/flake/flake.cc
+++ b/src/libexpr/flake/flake.cc
@@ -645,29 +645,28 @@ LockedFlake lockFlake(
auto newLockFileS = fmt("%s\n", newLockFile);
- if (lockFlags.outputLockFilePath)
+ if (lockFlags.outputLockFilePath) {
+ if (lockFlags.commitLockFile)
+ throw Error("'--commit-lock-file' and '--output-lock-file' are incompatible");
writeFile(*lockFlags.outputLockFilePath, newLockFileS);
- else {
+ } else {
auto relPath = (topRef.subdir == "" ? "" : topRef.subdir + "/") + "flake.lock";
- auto outputLockFilePath = sourcePath ? std::optional{*sourcePath + "/" + relPath} : std::nullopt;
+ auto outputLockFilePath = *sourcePath + "/" + relPath;
- bool lockFileExists = pathExists(*outputLockFilePath);
+ bool lockFileExists = pathExists(outputLockFilePath);
if (lockFileExists) {
auto s = chomp(diff);
if (s.empty())
- warn("updating lock file '%s'", *outputLockFilePath);
+ warn("updating lock file '%s'", outputLockFilePath);
else
- warn("updating lock file '%s':\n%s", *outputLockFilePath, s);
+ warn("updating lock file '%s':\n%s", outputLockFilePath, s);
} else
- warn("creating lock file '%s'", *outputLockFilePath);
+ warn("creating lock file '%s'", outputLockFilePath);
std::optional<std::string> commitMessage = std::nullopt;
if (lockFlags.commitLockFile) {
- if (lockFlags.outputLockFilePath) {
- throw Error("--commit-lock-file and --output-lock-file are currently incompatible");
- }
std::string cm;
cm = fetchSettings.commitLockFileSummary.get();