radicle-surf: Namespace using RefString

A `Namespace` is a '/' separated list of components, where each
component represents another level of the namespaces hierarchy. Notice
that a `RefString` is also a '/' separated list of components, thus it
could be reused to define a `Namespace`.

This change uses this observation and reworks `Namespace` to be backed
by a `RefString`.

This naturally leads to defining its helper functions to return
`Namespaced` and `NamespacedPattern` reference names. They are
reworked to take a `Qualified` for regular reference names and
`QualifiedPattern` for refspec names, respectively.

This leads to changing the backing vector of `Glob` to use
`QualifiedPattern` instead of `PatternString`.

While changing `Glob`, it was also noticed that the PhantomData was
not used correctly -- all `impl`s used a generic parameter. This was
changed to use the `Namespace`, `Tag`, and `Branch` types directly,
providing the type-safety that would be expected.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny
2022-11-18 11:13:37 +00:00
parent 2b5a34a703
commit 1ac99ac456
5 changed files with 243 additions and 85 deletions
+1 -1
View File
@@ -194,7 +194,7 @@ pub fn commit<R: git::Revision>(repo: &RepositoryRef, rev: R) -> Result<Commit,
}
let branches = repo
.revision_branches(&sha1, &Glob::heads("*")?.and_remotes("*")?)?
.revision_branches(&sha1, Glob::heads("*")?.and_remotes("*")?)?
.into_iter()
.map(|b| b.refname().into())
.collect();