aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libstore/fetchers/git.cc11
-rw-r--r--src/libstore/fetchers/mercurial.cc9
-rw-r--r--tests/flakes.sh5
3 files changed, 15 insertions, 10 deletions
diff --git a/src/libstore/fetchers/git.cc b/src/libstore/fetchers/git.cc
index 67cb5a9e0..0101744bd 100644
--- a/src/libstore/fetchers/git.cc
+++ b/src/libstore/fetchers/git.cc
@@ -104,6 +104,7 @@ struct GitInput : Input
std::string to_string() const override
{
ParsedURL url2(url);
+ if (url2.scheme != "git") url2.scheme = "git+" + url2.scheme;
if (rev) url2.query.insert_or_assign("rev", rev->gitRev());
if (ref) url2.query.insert_or_assign("ref", *ref);
return url2.to_string();
@@ -159,19 +160,19 @@ struct GitInput : Input
std::optional<Path> getSourcePath() const override
{
- if (url.scheme == "git+file" && !ref && !rev)
+ if (url.scheme == "file" && !ref && !rev)
return url.path;
return {};
}
std::pair<bool, std::string> getActualUrl() const
{
- // Don't clone git+file:// URIs (but otherwise treat them the
+ // Don't clone file:// URIs (but otherwise treat them the
// same as remote URIs, i.e. don't use the working tree or
// HEAD).
static bool forceHttp = getEnv("_NIX_FORCE_HTTP") == "1"; // for testing
- bool isLocal = url.scheme == "git+file" && !forceHttp;
- return {isLocal, isLocal ? url.path : std::string(url.base, 4)};
+ bool isLocal = url.scheme == "file" && !forceHttp;
+ return {isLocal, isLocal ? url.path : url.base};
}
std::pair<Tree, std::shared_ptr<const Input>> fetchTreeInternal(nix::ref<Store> store) const override
@@ -382,7 +383,7 @@ struct GitInputScheme : InputScheme
url.scheme != "git+file") return nullptr;
auto url2(url);
- // FIXME: strip git+
+ if (hasPrefix(url2.scheme, "git+")) url2.scheme = std::string(url2.scheme, 4);
url2.query.clear();
Input::Attrs attrs;
diff --git a/src/libstore/fetchers/mercurial.cc b/src/libstore/fetchers/mercurial.cc
index 0eb81d014..9b8c2132c 100644
--- a/src/libstore/fetchers/mercurial.cc
+++ b/src/libstore/fetchers/mercurial.cc
@@ -46,6 +46,7 @@ struct MercurialInput : Input
std::string to_string() const override
{
ParsedURL url2(url);
+ url2.scheme = "hg+" + url2.scheme;
if (rev) url2.query.insert_or_assign("rev", rev->gitRev());
if (ref) url2.query.insert_or_assign("ref", *ref);
return url2.to_string();
@@ -78,15 +79,15 @@ struct MercurialInput : Input
std::optional<Path> getSourcePath() const
{
- if (url.scheme == "hg+file" && !ref && !rev)
+ if (url.scheme == "file" && !ref && !rev)
return url.path;
return {};
}
std::pair<bool, std::string> getActualUrl() const
{
- bool isLocal = url.scheme == "hg+file";
- return {isLocal, isLocal ? url.path : std::string(url.base, 3)};
+ bool isLocal = url.scheme == "file";
+ return {isLocal, isLocal ? url.path : url.base};
}
std::pair<Tree, std::shared_ptr<const Input>> fetchTreeInternal(nix::ref<Store> store) const override
@@ -273,7 +274,7 @@ struct MercurialInputScheme : InputScheme
url.scheme != "hg+file") return nullptr;
auto url2(url);
- // FIXME: strip hg+
+ url2.scheme = std::string(url2.scheme, 3);
url2.query.clear();
Input::Attrs attrs;
diff --git a/tests/flakes.sh b/tests/flakes.sh
index 1d0da556c..5a00d8671 100644
--- a/tests/flakes.sh
+++ b/tests/flakes.sh
@@ -516,7 +516,10 @@ cat > $flake3Dir/flake.nix <<EOF
{
edition = 201909;
- inputs.flake2.inputs.flake1.url = git+file://$flake7Dir;
+ inputs.flake2.inputs.flake1 = {
+ type = "git";
+ url = file://$flake7Dir;
+ };
outputs = { self, flake2 }: {
};