mirror of
https://github.com/NixOS/nix
synced 2025-06-28 05:21:16 +02:00
Remove superfluous TreeInfo::rev field
This commit is contained in:
parent
b9d64f9318
commit
887730aab3
9 changed files with 36 additions and 38 deletions
|
@ -567,17 +567,21 @@ LockedFlake lockFlake(
|
|||
return LockedFlake { .flake = std::move(flake), .lockFile = std::move(newLockFile) };
|
||||
}
|
||||
|
||||
static void emitSourceInfoAttrs(EvalState & state, const fetchers::Tree & sourceInfo, Value & vAttrs)
|
||||
static void emitSourceInfoAttrs(
|
||||
EvalState & state,
|
||||
const FlakeRef & flakeRef,
|
||||
const fetchers::Tree & sourceInfo,
|
||||
Value & vAttrs)
|
||||
{
|
||||
assert(state.store->isValidPath(sourceInfo.storePath));
|
||||
auto pathS = state.store->printStorePath(sourceInfo.storePath);
|
||||
mkString(*state.allocAttr(vAttrs, state.sOutPath), pathS, {pathS});
|
||||
|
||||
if (sourceInfo.info.rev) {
|
||||
if (auto rev = flakeRef.input->getRev()) {
|
||||
mkString(*state.allocAttr(vAttrs, state.symbols.create("rev")),
|
||||
sourceInfo.info.rev->gitRev());
|
||||
rev->gitRev());
|
||||
mkString(*state.allocAttr(vAttrs, state.symbols.create("shortRev")),
|
||||
sourceInfo.info.rev->gitShortRev());
|
||||
rev->gitShortRev());
|
||||
}
|
||||
|
||||
if (sourceInfo.info.revCount)
|
||||
|
@ -639,7 +643,7 @@ static void prim_callFlake(EvalState & state, const Pos & pos, Value * * args, V
|
|||
|
||||
mkString(*state.allocAttr(v, state.sOutPath), pathS, {pathS});
|
||||
|
||||
emitSourceInfoAttrs(state, sourceInfo, v);
|
||||
emitSourceInfoAttrs(state, resolvedRef, sourceInfo, v);
|
||||
|
||||
v.attrs->sort();
|
||||
}
|
||||
|
@ -672,7 +676,7 @@ void callFlake(EvalState & state,
|
|||
|
||||
auto & vSourceInfo = *state.allocValue();
|
||||
state.mkAttrs(vSourceInfo, 8);
|
||||
emitSourceInfoAttrs(state, *flake.sourceInfo, vSourceInfo);
|
||||
emitSourceInfoAttrs(state, flake.resolvedRef, *flake.sourceInfo, vSourceInfo);
|
||||
vSourceInfo.attrs->sort();
|
||||
|
||||
vInputs.attrs->push_back(Attr(state.sSelf, &vRes));
|
||||
|
|
|
@ -58,10 +58,6 @@ static TreeInfo parseTreeInfo(const nlohmann::json & json)
|
|||
else
|
||||
throw Error("attribute 'narHash' missing in lock file");
|
||||
|
||||
j = i2.find("rev");
|
||||
if (j != i2.end())
|
||||
info.rev = Hash((std::string) *j, htSHA1);
|
||||
|
||||
j = i2.find("revCount");
|
||||
if (j != i2.end())
|
||||
info.revCount = *j;
|
||||
|
@ -97,8 +93,6 @@ static nlohmann::json treeInfoToJson(const TreeInfo & info)
|
|||
nlohmann::json json;
|
||||
assert(info.narHash);
|
||||
json["narHash"] = info.narHash.to_string(SRI);
|
||||
if (info.rev)
|
||||
json["rev"] = info.rev->gitRev();
|
||||
if (info.revCount)
|
||||
json["revCount"] = *info.revCount;
|
||||
if (info.lastModified)
|
||||
|
|
|
@ -57,14 +57,14 @@ static void prim_fetchGit(EvalState & state, const Pos & pos, Value * * args, Va
|
|||
// FIXME: use name
|
||||
auto input = inputFromURL(parsedUrl);
|
||||
|
||||
auto tree = input->fetchTree(state.store).first;
|
||||
auto [tree, input2] = input->fetchTree(state.store);
|
||||
|
||||
state.mkAttrs(v, 8);
|
||||
auto storePath = state.store->printStorePath(tree.storePath);
|
||||
mkString(*state.allocAttr(v, state.sOutPath), storePath, PathSet({storePath}));
|
||||
// Backward compatibility: set 'rev' to
|
||||
// 0000000000000000000000000000000000000000 for a dirty tree.
|
||||
auto rev2 = tree.info.rev.value_or(Hash(htSHA1));
|
||||
auto rev2 = input2->getRev().value_or(Hash(htSHA1));
|
||||
mkString(*state.allocAttr(v, state.symbols.create("rev")), rev2.gitRev());
|
||||
mkString(*state.allocAttr(v, state.symbols.create("shortRev")), rev2.gitShortRev());
|
||||
assert(tree.info.revCount);
|
||||
|
|
|
@ -73,7 +73,7 @@ static void prim_fetchMercurial(EvalState & state, const Pos & pos, Value * * ar
|
|||
mkString(*state.allocAttr(v, state.symbols.create("branch")), *input2->getRef());
|
||||
// Backward compatibility: set 'rev' to
|
||||
// 0000000000000000000000000000000000000000 for a dirty tree.
|
||||
auto rev2 = tree.info.rev.value_or(Hash(htSHA1));
|
||||
auto rev2 = input2->getRev().value_or(Hash(htSHA1));
|
||||
mkString(*state.allocAttr(v, state.symbols.create("rev")), rev2.gitRev());
|
||||
mkString(*state.allocAttr(v, state.symbols.create("shortRev")), std::string(rev2.gitRev(), 0, 12));
|
||||
if (tree.info.revCount)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue