aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/fetchers/git.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/fetchers/git.cc')
-rw-r--r--src/libstore/fetchers/git.cc27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/libstore/fetchers/git.cc b/src/libstore/fetchers/git.cc
index 1350c5754..2a7ce5432 100644
--- a/src/libstore/fetchers/git.cc
+++ b/src/libstore/fetchers/git.cc
@@ -74,9 +74,9 @@ struct GitInput : Input
std::optional<Hash> rev;
GitInput(const ParsedURL & url) : url(url)
- {
- type = "git";
- }
+ { }
+
+ std::string type() const override { return "git"; }
bool operator ==(const Input & other) const override
{
@@ -105,6 +105,17 @@ struct GitInput : Input
return url2.to_string();
}
+ Attrs toAttrsInternal() const override
+ {
+ Attrs attrs;
+ attrs.emplace("url", url.to_string());
+ if (ref)
+ attrs.emplace("ref", *ref);
+ if (rev)
+ attrs.emplace("rev", rev->gitRev());
+ return attrs;
+ }
+
void clone(const Path & destDir) const override
{
auto [isLocal, actualUrl] = getActualUrl();
@@ -379,6 +390,16 @@ struct GitInputScheme : InputScheme
return input;
}
+
+ std::unique_ptr<Input> inputFromAttrs(const Input::Attrs & attrs) override
+ {
+ if (maybeGetStrAttr(attrs, "type") != "git") return {};
+ auto input = std::make_unique<GitInput>(parseURL(getStrAttr(attrs, "url")));
+ input->ref = maybeGetStrAttr(attrs, "ref");
+ if (auto rev = maybeGetStrAttr(attrs, "rev"))
+ input->rev = Hash(*rev, htSHA1);
+ return input;
+ }
};
static auto r1 = OnStartup([] { registerInputScheme(std::make_unique<GitInputScheme>()); });