diff options
Diffstat (limited to 'src/libfetchers/github.cc')
-rw-r--r-- | src/libfetchers/github.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libfetchers/github.cc b/src/libfetchers/github.cc index 8675a5a66..c01917dcc 100644 --- a/src/libfetchers/github.cc +++ b/src/libfetchers/github.cc @@ -64,6 +64,13 @@ struct GitHubInput : Input return attrs; } + void clone(const Path & destDir) const override + { + std::shared_ptr<const Input> input = inputFromURL(fmt("git+ssh://git@github.com/%s/%s.git", owner, repo)); + input = input->applyOverrides(ref.value_or("master"), rev); + input->clone(destDir); + } + std::pair<Tree, std::shared_ptr<const Input>> fetchTreeInternal(nix::ref<Store> store) const override { auto rev = this->rev; @@ -126,6 +133,20 @@ struct GitHubInput : Input return {std::move(tree), input}; } + + std::shared_ptr<const Input> applyOverrides( + std::optional<std::string> ref, + std::optional<Hash> rev) const override + { + if (!ref && !rev) return shared_from_this(); + + auto res = std::make_shared<GitHubInput>(*this); + + if (ref) res->ref = ref; + if (rev) res->rev = rev; + + return res; + } }; struct GitHubInputScheme : InputScheme |