forked from lix-project/lix
fetchGit: Return revCount for dirty working trees
This commit is contained in:
parent
0cbda84f5b
commit
bc259192b4
|
@ -68,6 +68,7 @@ GitInfo exportGit(ref<Store> store, std::string uri,
|
||||||
};
|
};
|
||||||
|
|
||||||
gitInfo.storePath = store->addToStore("source", uri, true, htSHA256, filter);
|
gitInfo.storePath = store->addToStore("source", uri, true, htSHA256, filter);
|
||||||
|
gitInfo.revCount = std::stoull(runProgram("git", true, { "-C", uri, "rev-list", "--count", "HEAD" }));
|
||||||
|
|
||||||
return gitInfo;
|
return gitInfo;
|
||||||
}
|
}
|
||||||
|
@ -200,7 +201,7 @@ GitInfo exportGit(ref<Store> store, std::string uri,
|
||||||
json["uri"] = uri;
|
json["uri"] = uri;
|
||||||
json["name"] = name;
|
json["name"] = name;
|
||||||
json["rev"] = gitInfo.rev.gitRev();
|
json["rev"] = gitInfo.rev.gitRev();
|
||||||
json["revCount"] = *gitInfo.revCount;
|
json["revCount"] = gitInfo.revCount;
|
||||||
|
|
||||||
writeFile(storeLink, json.dump());
|
writeFile(storeLink, json.dump());
|
||||||
|
|
||||||
|
@ -254,7 +255,7 @@ static void prim_fetchGit(EvalState & state, const Pos & pos, Value * * args, Va
|
||||||
mkString(*state.allocAttr(v, state.sOutPath), gitInfo.storePath, PathSet({gitInfo.storePath}));
|
mkString(*state.allocAttr(v, state.sOutPath), gitInfo.storePath, PathSet({gitInfo.storePath}));
|
||||||
mkString(*state.allocAttr(v, state.symbols.create("rev")), gitInfo.rev.gitRev());
|
mkString(*state.allocAttr(v, state.symbols.create("rev")), gitInfo.rev.gitRev());
|
||||||
mkString(*state.allocAttr(v, state.symbols.create("shortRev")), gitInfo.rev.gitShortRev());
|
mkString(*state.allocAttr(v, state.symbols.create("shortRev")), gitInfo.rev.gitShortRev());
|
||||||
mkInt(*state.allocAttr(v, state.symbols.create("revCount")), gitInfo.revCount.value_or(0));
|
mkInt(*state.allocAttr(v, state.symbols.create("revCount")), gitInfo.revCount);
|
||||||
v.attrs->sort();
|
v.attrs->sort();
|
||||||
|
|
||||||
if (state.allowedPaths)
|
if (state.allowedPaths)
|
||||||
|
|
|
@ -11,7 +11,7 @@ struct GitInfo
|
||||||
Path storePath;
|
Path storePath;
|
||||||
std::string ref;
|
std::string ref;
|
||||||
Hash rev{htSHA1};
|
Hash rev{htSHA1};
|
||||||
std::optional<uint64_t> revCount;
|
uint64_t revCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
GitInfo exportGit(ref<Store> store, std::string uri,
|
GitInfo exportGit(ref<Store> store, std::string uri,
|
||||||
|
|
Loading…
Reference in a new issue