#6699 flake init: Apply suggestions of @thufschmitt

This commit is contained in:
Manu [tennox] 2022-06-26 18:12:30 +01:00
parent 58cbbdc5e7
commit 4374e3ec67

View file

@ -742,7 +742,6 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
std::vector<Path> changedFiles;
std::vector<Path> conflictedFiles;
auto success = false;
std::function<void(const Path & from, const Path & to)> copyDir;
copyDir = [&](const Path & from, const Path & to)
@ -761,7 +760,6 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
auto contents2 = readFile(to2);
if (contents != contents2) {
printError("refusing to overwrite existing file '%s'\n please merge it manually with '%s'", to2, from2);
success = false;
conflictedFiles.push_back(to2);
} else {
notice("skipping identical file: %s", from2);
@ -775,7 +773,6 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
if (pathExists(to2)) {
if (readLink(to2) != target) {
printError("refusing to overwrite existing file '%s'\n please merge it manually with '%s'", to2, from2);
success = false;
conflictedFiles.push_back(to2);
} else {
notice("skipping identical file: %s", from2);
@ -803,8 +800,8 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
notice(renderMarkdownToTerminal(welcomeText->getString()));
}
if (!success)
throw Error("Encountered %d conflicts - please merge manually", conflictedFiles.size());
if (!conflictedFiles.empty())
throw Error("Encountered %d conflicts - see above", conflictedFiles.size());
}
};