Skip to content

Commit

Permalink
Merge pull request #9198 from edolstra/remove-direct
Browse files Browse the repository at this point in the history
Input: Remove 'direct' field
  • Loading branch information
edolstra authored Oct 20, 2023
2 parents 81ed1d5 + 0f7e9d0 commit 091e5b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/libfetchers/fetchers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ std::string Input::to_string() const
return toURL().to_string();
}

bool Input::isDirect() const
{
return !scheme || scheme->isDirect(*this);
}

Attrs Input::toAttrs() const
{
return attrs;
Expand Down
6 changes: 4 additions & 2 deletions src/libfetchers/fetchers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ struct Input
std::shared_ptr<InputScheme> scheme; // note: can be null
Attrs attrs;
bool locked = false;
bool direct = true;

/**
* path of the parent of this input, used for relative path resolution
Expand Down Expand Up @@ -71,7 +70,7 @@ public:
* Check whether this is a "direct" input, that is, not
* one that goes through a registry.
*/
bool isDirect() const { return direct; }
bool isDirect() const;

/**
* Check whether this is a "locked" input, that is,
Expand Down Expand Up @@ -152,6 +151,9 @@ struct InputScheme
* Is this `InputScheme` part of an experimental feature?
*/
virtual std::optional<ExperimentalFeature> experimentalFeature();

virtual bool isDirect(const Input & input) const
{ return true; }
};

void registerInputScheme(std::shared_ptr<InputScheme> && fetcher);
Expand Down
5 changes: 3 additions & 2 deletions src/libfetchers/indirect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ struct IndirectInputScheme : InputScheme
// FIXME: forbid query params?

Input input;
input.direct = false;
input.attrs.insert_or_assign("type", "indirect");
input.attrs.insert_or_assign("id", id);
if (rev) input.attrs.insert_or_assign("rev", rev->gitRev());
Expand All @@ -63,7 +62,6 @@ struct IndirectInputScheme : InputScheme
throw BadURL("'%s' is not a valid flake ID", id);

Input input;
input.direct = false;
input.attrs = attrs;
return input;
}
Expand Down Expand Up @@ -98,6 +96,9 @@ struct IndirectInputScheme : InputScheme
{
return Xp::Flakes;
}

bool isDirect(const Input & input) const override
{ return false; }
};

static auto rIndirectInputScheme = OnStartup([] { registerInputScheme(std::make_unique<IndirectInputScheme>()); });
Expand Down

0 comments on commit 091e5b4

Please sign in to comment.