git-ref-format: qualified macro

Add a `qualified!` macro to the set of git-ref-format macros. This
allows the construction of a `refs/<cat>/<name>` reference from a
string literal.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
This commit is contained in:
Fintan Halpenny
2022-10-12 17:00:05 +01:00
parent 93d92ede2d
commit 339d7fc097
3 changed files with 65 additions and 2 deletions
+16 -1
View File
@@ -1,13 +1,28 @@
// Copyright © 2022 The Radicle Link Contributors
// SPDX-License-Identifier: GPL-3.0-or-later
use git_ref_format::{component, name, refname, refspec, Error, Qualified, RefStr, RefString};
use git_ref_format::{
component,
name,
qualified,
refname,
refspec,
Error,
Qualified,
RefStr,
RefString,
};
#[test]
fn refname_macro_works() {
assert_eq!("refs/heads/main", refname!("refs/heads/main").as_str())
}
#[test]
fn qualified_macro_works() {
assert_eq!("refs/heads/main", qualified!("refs/heads/main").as_str())
}
#[test]
fn component_macro_works() {
assert_eq!("self", name::component!("self").as_str())