diff options
author | Vincent Ambo <mail@tazj.in> | 2020-08-21T02·29+0100 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2020-08-21T03·55+0000 |
commit | 1443298657156107704b5d9fcfa7356ee8fa8789 (patch) | |
tree | 3c4009acabdc90799d11084dbe5df58f39b90beb /third_party/nix/src/libexpr/primops/fetchGit.cc | |
parent | 7edbe59c6c70cd085fc68c4317c3a71a40ac21e5 (diff) |
style(tvix): Add missing braces in expressions r/1703
The previous clang-tidy invocation missed some header files, which has now been rectified. Change-Id: I31547754fbf52f439dc7aeefb08ab90bd50c4156 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1831 Reviewed-by: glittershark <grfn@gws.fyi> Tested-by: BuildkiteCI
Diffstat (limited to 'third_party/nix/src/libexpr/primops/fetchGit.cc')
-rw-r--r-- | third_party/nix/src/libexpr/primops/fetchGit.cc | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/third_party/nix/src/libexpr/primops/fetchGit.cc b/third_party/nix/src/libexpr/primops/fetchGit.cc index 2b2ca476cbbb..72b498d30b3e 100644 --- a/third_party/nix/src/libexpr/primops/fetchGit.cc +++ b/third_party/nix/src/libexpr/primops/fetchGit.cc @@ -30,8 +30,9 @@ std::regex revRegex("^[0-9a-fA-F]{40}$"); GitInfo exportGit(ref<Store> store, const std::string& uri, std::optional<std::string> ref, std::string rev, const std::string& name) { - if (evalSettings.pureEval && rev == "") + if (evalSettings.pureEval && rev == "") { throw Error("in pure evaluation mode, 'fetchGit' requires a Git revision"); + } if (!ref && rev == "" && absl::StartsWith(uri, "/") && pathExists(uri + "/.git")) { @@ -90,8 +91,9 @@ GitInfo exportGit(ref<Store> store, const std::string& uri, ref = "HEAD"s; } - if (rev != "" && !std::regex_match(rev, revRegex)) + if (rev != "" && !std::regex_match(rev, revRegex)) { throw Error("invalid Git revision '%s'", rev); + } deletePath(getCacheDir() + "/nix/git"); @@ -104,10 +106,11 @@ GitInfo exportGit(ref<Store> store, const std::string& uri, } Path localRefFile; - if (ref->compare(0, 5, "refs/") == 0) + if (ref->compare(0, 5, "refs/") == 0) { localRefFile = cacheDir + "/" + *ref; - else + } else { localRefFile = cacheDir + "/refs/heads/" + *ref; + } bool doFetch; time_t now = time(0); @@ -226,22 +229,24 @@ static void prim_fetchGit(EvalState& state, const Pos& pos, Value** args, for (auto& attr_iter : *args[0]->attrs) { auto& attr = attr_iter.second; std::string n(attr.name); - if (n == "url") + if (n == "url") { url = state.coerceToString(*attr.pos, *attr.value, context, false, false); - else if (n == "ref") + } else if (n == "ref") { ref = state.forceStringNoCtx(*attr.value, *attr.pos); - else if (n == "rev") + } else if (n == "rev") { rev = state.forceStringNoCtx(*attr.value, *attr.pos); - else if (n == "name") + } else if (n == "name") { name = state.forceStringNoCtx(*attr.value, *attr.pos); - else + } else { throw EvalError("unsupported argument '%s' to 'fetchGit', at %s", attr.name, *attr.pos); + } } - if (url.empty()) + if (url.empty()) { throw EvalError(format("'url' argument required, at %1%") % pos); + } } else { url = state.coerceToString(pos, *args[0], context, false, false); |