Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Oct 30, 2023
1 parent 15c430f commit 05316d4
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/libexpr/flake/flake.cc
Original file line number Diff line number Diff line change
Expand Up @@ -641,29 +641,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();
Expand Down

0 comments on commit 05316d4

Please sign in to comment.