forked from lix-project/lix
Restore the possibility to use a name
parameter in fetchGit
Accidentally broken by 7e5c79a2d2
This commit is contained in:
parent
7e5c79a2d2
commit
a654c1d81c
|
@ -72,13 +72,18 @@ void addURI(EvalState &state, fetchers::Attrs &attrs, Symbol name, std::string v
|
||||||
attrs.emplace(name, n == "url" ? fixURI(v, state) : v);
|
attrs.emplace(name, n == "url" ? fixURI(v, state) : v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct FetchTreeParams {
|
||||||
|
bool emptyRevFallback = false;
|
||||||
|
bool allowNameArgument = false;
|
||||||
|
};
|
||||||
|
|
||||||
static void fetchTree(
|
static void fetchTree(
|
||||||
EvalState &state,
|
EvalState &state,
|
||||||
const Pos &pos,
|
const Pos &pos,
|
||||||
Value **args,
|
Value **args,
|
||||||
Value &v,
|
Value &v,
|
||||||
const std::optional<std::string> type,
|
const std::optional<std::string> type,
|
||||||
bool emptyRevFallback = false
|
const FetchTreeParams & params = FetchTreeParams{}
|
||||||
) {
|
) {
|
||||||
fetchers::Input input;
|
fetchers::Input input;
|
||||||
PathSet context;
|
PathSet context;
|
||||||
|
@ -119,11 +124,12 @@ static void fetchTree(
|
||||||
.errPos = pos
|
.errPos = pos
|
||||||
});
|
});
|
||||||
|
|
||||||
if (auto nameIter = attrs.find("name"); nameIter != attrs.end())
|
if (!params.allowNameArgument)
|
||||||
throw Error({
|
if (auto nameIter = attrs.find("name"); nameIter != attrs.end())
|
||||||
.msg = hintfmt("attribute 'name' isn’t supported in call to 'fetchTree'"),
|
throw Error({
|
||||||
.errPos = pos
|
.msg = hintfmt("attribute 'name' isn’t supported in call to 'fetchTree'"),
|
||||||
});
|
.errPos = pos
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
input = fetchers::Input::fromAttrs(std::move(attrs));
|
input = fetchers::Input::fromAttrs(std::move(attrs));
|
||||||
|
@ -151,13 +157,13 @@ static void fetchTree(
|
||||||
if (state.allowedPaths)
|
if (state.allowedPaths)
|
||||||
state.allowedPaths->insert(tree.actualPath);
|
state.allowedPaths->insert(tree.actualPath);
|
||||||
|
|
||||||
emitTreeAttrs(state, tree, input2, v, emptyRevFallback);
|
emitTreeAttrs(state, tree, input2, v, params.emptyRevFallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prim_fetchTree(EvalState & state, const Pos & pos, Value * * args, Value & v)
|
static void prim_fetchTree(EvalState & state, const Pos & pos, Value * * args, Value & v)
|
||||||
{
|
{
|
||||||
settings.requireExperimentalFeature("flakes");
|
settings.requireExperimentalFeature("flakes");
|
||||||
fetchTree(state, pos, args, v, std::nullopt);
|
fetchTree(state, pos, args, v, std::nullopt, FetchTreeParams { .allowNameArgument = false });
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: document
|
// FIXME: document
|
||||||
|
@ -299,7 +305,7 @@ static RegisterPrimOp primop_fetchTarball({
|
||||||
|
|
||||||
static void prim_fetchGit(EvalState &state, const Pos &pos, Value **args, Value &v)
|
static void prim_fetchGit(EvalState &state, const Pos &pos, Value **args, Value &v)
|
||||||
{
|
{
|
||||||
fetchTree(state, pos, args, v, "git", true);
|
fetchTree(state, pos, args, v, "git", FetchTreeParams { .emptyRevFallback = true, .allowNameArgument = true });
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterPrimOp primop_fetchGit({
|
static RegisterPrimOp primop_fetchGit({
|
||||||
|
|
Loading…
Reference in a new issue