forked from lix-project/lix
#6699 flake init: Apply suggestions of @thufschmitt
This commit is contained in:
parent
58cbbdc5e7
commit
4374e3ec67
|
@ -742,7 +742,6 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
|
||||||
|
|
||||||
std::vector<Path> changedFiles;
|
std::vector<Path> changedFiles;
|
||||||
std::vector<Path> conflictedFiles;
|
std::vector<Path> conflictedFiles;
|
||||||
auto success = false;
|
|
||||||
|
|
||||||
std::function<void(const Path & from, const Path & to)> copyDir;
|
std::function<void(const Path & from, const Path & to)> copyDir;
|
||||||
copyDir = [&](const Path & from, const Path & to)
|
copyDir = [&](const Path & from, const Path & to)
|
||||||
|
@ -761,7 +760,6 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
|
||||||
auto contents2 = readFile(to2);
|
auto contents2 = readFile(to2);
|
||||||
if (contents != contents2) {
|
if (contents != contents2) {
|
||||||
printError("refusing to overwrite existing file '%s'\n please merge it manually with '%s'", to2, from2);
|
printError("refusing to overwrite existing file '%s'\n please merge it manually with '%s'", to2, from2);
|
||||||
success = false;
|
|
||||||
conflictedFiles.push_back(to2);
|
conflictedFiles.push_back(to2);
|
||||||
} else {
|
} else {
|
||||||
notice("skipping identical file: %s", from2);
|
notice("skipping identical file: %s", from2);
|
||||||
|
@ -775,7 +773,6 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
|
||||||
if (pathExists(to2)) {
|
if (pathExists(to2)) {
|
||||||
if (readLink(to2) != target) {
|
if (readLink(to2) != target) {
|
||||||
printError("refusing to overwrite existing file '%s'\n please merge it manually with '%s'", to2, from2);
|
printError("refusing to overwrite existing file '%s'\n please merge it manually with '%s'", to2, from2);
|
||||||
success = false;
|
|
||||||
conflictedFiles.push_back(to2);
|
conflictedFiles.push_back(to2);
|
||||||
} else {
|
} else {
|
||||||
notice("skipping identical file: %s", from2);
|
notice("skipping identical file: %s", from2);
|
||||||
|
@ -803,8 +800,8 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
|
||||||
notice(renderMarkdownToTerminal(welcomeText->getString()));
|
notice(renderMarkdownToTerminal(welcomeText->getString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success)
|
if (!conflictedFiles.empty())
|
||||||
throw Error("Encountered %d conflicts - please merge manually", conflictedFiles.size());
|
throw Error("Encountered %d conflicts - see above", conflictedFiles.size());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue