Minor cleanup in libexpr/flake/flake.cc

(cherry picked from commit 05316d401f)
Change-Id: I6ba0b55709f5fe21beb4e9f3bf72ee28715d15f3
This commit is contained in:
Eelco Dolstra 2023-10-30 17:03:06 +01:00 committed by lunaphied
parent b525d0f20c
commit aa7653608d

View file

@ -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();