Warn about --override-input / --update-input flags that don't match an input
This commit is contained in:
parent
2287e2f279
commit
2fccef0c59
|
@ -314,6 +314,7 @@ LockedFlake lockFlake(
|
||||||
|
|
||||||
// FIXME: check whether all overrides are used.
|
// FIXME: check whether all overrides are used.
|
||||||
std::map<InputPath, FlakeInput> overrides;
|
std::map<InputPath, FlakeInput> overrides;
|
||||||
|
std::set<InputPath> overridesUsed, updatesUsed;
|
||||||
|
|
||||||
for (auto & i : lockFlags.inputOverrides)
|
for (auto & i : lockFlags.inputOverrides)
|
||||||
overrides.insert_or_assign(i.first, FlakeInput { .ref = i.second });
|
overrides.insert_or_assign(i.first, FlakeInput { .ref = i.second });
|
||||||
|
@ -363,6 +364,7 @@ LockedFlake lockFlake(
|
||||||
ancestors? */
|
ancestors? */
|
||||||
auto i = overrides.find(inputPath);
|
auto i = overrides.find(inputPath);
|
||||||
bool hasOverride = i != overrides.end();
|
bool hasOverride = i != overrides.end();
|
||||||
|
if (hasOverride) overridesUsed.insert(inputPath);
|
||||||
auto & input = hasOverride ? i->second : input2;
|
auto & input = hasOverride ? i->second : input2;
|
||||||
|
|
||||||
/* Resolve 'follows' later (since it may refer to an input
|
/* Resolve 'follows' later (since it may refer to an input
|
||||||
|
@ -385,6 +387,8 @@ LockedFlake lockFlake(
|
||||||
don't have a --update-input flag for this input? */
|
don't have a --update-input flag for this input? */
|
||||||
std::shared_ptr<const LockedNode> oldLock;
|
std::shared_ptr<const LockedNode> oldLock;
|
||||||
|
|
||||||
|
updatesUsed.insert(inputPath);
|
||||||
|
|
||||||
if (oldNode && !lockFlags.inputUpdates.count(inputPath)) {
|
if (oldNode && !lockFlags.inputUpdates.count(inputPath)) {
|
||||||
auto oldLockIt = oldNode->inputs.find(id);
|
auto oldLockIt = oldNode->inputs.find(id);
|
||||||
if (oldLockIt != oldNode->inputs.end())
|
if (oldLockIt != oldNode->inputs.end())
|
||||||
|
@ -515,6 +519,15 @@ LockedFlake lockFlake(
|
||||||
fromParentNode->inputs.insert_or_assign(from.back(), toNode);
|
fromParentNode->inputs.insert_or_assign(from.back(), toNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto & i : lockFlags.inputOverrides)
|
||||||
|
if (!overridesUsed.count(i.first))
|
||||||
|
warn("the flag '--override-input %s %s' does not match any input",
|
||||||
|
concatStringsSep("/", i.first), i.second);
|
||||||
|
|
||||||
|
for (auto & i : lockFlags.inputUpdates)
|
||||||
|
if (!updatesUsed.count(i))
|
||||||
|
warn("the flag '--update-input %s' does not match any input", concatStringsSep("/", i));
|
||||||
|
|
||||||
debug("new lock file: %s", newLockFile);
|
debug("new lock file: %s", newLockFile);
|
||||||
|
|
||||||
/* Check whether we need to / can write the new lock file. */
|
/* Check whether we need to / can write the new lock file. */
|
||||||
|
|
Loading…
Reference in a new issue