diff --git a/radicle-git-ext/git-ref-format/core/src/deriv.rs b/radicle-git-ext/git-ref-format/core/src/deriv.rs index e67eb78..00c0a5f 100644 --- a/radicle-git-ext/git-ref-format/core/src/deriv.rs +++ b/radicle-git-ext/git-ref-format/core/src/deriv.rs @@ -267,9 +267,10 @@ impl Display for Qualified<'_> { /// A [`Qualified`] ref under a git namespace. /// /// A ref is namespaced if it starts with "refs/namespaces/", another path -/// component, and "refs/". Eg. +/// component, and "refs" or "HEAD". Eg. /// /// refs/namespaces/xyz/refs/heads/main +/// refs/namespaces/xyz/HEAD /// /// Note that namespaces can be nested, so the result of /// [`Namespaced::strip_namespace`] may be convertible to a [`Namespaced`] @@ -365,7 +366,7 @@ impl<'a> From<&'a RefStr> for Option> { fn from(rs: &'a RefStr) -> Self { let mut cs = rs.iter(); match (cs.next()?, cs.next()?, cs.next()?, cs.next()?) { - ("refs", "namespaces", _, "refs") => Some(Namespaced(Cow::from(rs))), + ("refs", "namespaces", _, "refs" | "HEAD") => Some(Namespaced(Cow::from(rs))), _ => None, } diff --git a/radicle-git-ext/t/src/git_ref_format/tests.rs b/radicle-git-ext/t/src/git_ref_format/tests.rs index 8a43669..e638bcf 100644 --- a/radicle-git-ext/t/src/git_ref_format/tests.rs +++ b/radicle-git-ext/t/src/git_ref_format/tests.rs @@ -156,6 +156,17 @@ fn namespaced() { ) } +#[test] +fn namespaced_head() { + assert_eq!( + "refs/namespaces/foo/HEAD", + refname!("refs/namespaces/foo/HEAD") + .to_namespaced() + .unwrap() + .as_str() + ) +} + #[test] fn not_namespaced() { assert!(name::REFS_HEADS_MAIN.to_namespaced().is_none())