aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/flake/flakeref.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-09-18 23:59:45 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-09-18 23:59:45 +0200
commitaeb7148afd56b228604b79373a45793d36d660a3 (patch)
tree7c25eceaf1196fbe942c3bca065682e4e953d891 /src/libexpr/flake/flakeref.cc
parentc67407172d8383394f4962ad177c84bf04529e5e (diff)
Some effort to minimize flake dependencies
For example, if the top-level flake depends on "nixpkgs/release-19.03", and one of its dependencies depends on "nixpkgs", then the latter will be mapped to "nixpkgs/release-19.03", rather than whatever the default branch of "nixpkgs" is. Thus you get only one "nixpkgs" dependency rather than two. This currently only works in a breadth-first way, so the other way around (i.e. if the top-level flake depends on "nixpkgs", and a dependency depends on "nixpkgs/release-19.03") still results in two "nixpkgs" dependencies.
Diffstat (limited to 'src/libexpr/flake/flakeref.cc')
-rw-r--r--src/libexpr/flake/flakeref.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libexpr/flake/flakeref.cc b/src/libexpr/flake/flakeref.cc
index 4ce326c0b..4930d03ce 100644
--- a/src/libexpr/flake/flakeref.cc
+++ b/src/libexpr/flake/flakeref.cc
@@ -255,6 +255,23 @@ FlakeRef FlakeRef::baseRef() const // Removes the ref and rev from a FlakeRef.
return result;
}
+bool FlakeRef::contains(const FlakeRef & other) const
+{
+ if (!(data == other.data))
+ return false;
+
+ if (ref && ref != other.ref)
+ return false;
+
+ if (rev && rev != other.rev)
+ return false;
+
+ if (subdir != other.subdir)
+ return false;
+
+ return true;
+}
+
std::optional<FlakeRef> parseFlakeRef(
const std::string & uri, bool allowRelative)
{