mirror of
https://seed.radicle.dev/rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt.git
synced 2026-11-29 14:10:27 +08:00
radicle-surf: rework to use git-ref-format
The aim of this commit is to better represent the reference names using git-ref-format. The first places to change were the Branch and Tag types. For Branch, the previous types were simply wrappers around the names. They stay this way, using RefString instead. For Tag, the `name` field is replaced with RefString. Note: The parsing logic becomes easier here by utilising the Namespaced and Qualified types. The consequences of these changes meant that areas that used BranchName or TagName are changed to use RefString. Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
@@ -114,25 +114,21 @@ impl Serialize for BlobContent {
|
||||
///
|
||||
/// Will return [`Error`] if the project doesn't exist or a surf interaction
|
||||
/// fails.
|
||||
pub fn blob<P>(
|
||||
pub fn blob(
|
||||
repo: &RepositoryRef,
|
||||
maybe_revision: Option<Revision<P>>,
|
||||
maybe_revision: Option<Revision>,
|
||||
path: &str,
|
||||
) -> Result<Blob, Error>
|
||||
where
|
||||
P: ToString,
|
||||
{
|
||||
) -> Result<Blob, Error> {
|
||||
make_blob(repo, maybe_revision, path, content)
|
||||
}
|
||||
|
||||
fn make_blob<P, C>(
|
||||
fn make_blob<C>(
|
||||
repo: &RepositoryRef,
|
||||
maybe_revision: Option<Revision<P>>,
|
||||
maybe_revision: Option<Revision>,
|
||||
path: &str,
|
||||
content: C,
|
||||
) -> Result<Blob, Error>
|
||||
where
|
||||
P: ToString,
|
||||
C: FnOnce(&[u8]) -> BlobContent,
|
||||
{
|
||||
let revision = maybe_revision.unwrap();
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
use std::str::FromStr as _;
|
||||
|
||||
use git_ref_format::refname;
|
||||
#[cfg(feature = "serialize")]
|
||||
use serde::{
|
||||
ser::{SerializeStruct as _, Serializer},
|
||||
@@ -85,20 +86,17 @@ impl Serialize for TreeEntry {
|
||||
/// # Errors
|
||||
///
|
||||
/// Will return [`Error`] if any of the surf interactions fail.
|
||||
pub fn tree<P>(
|
||||
pub fn tree(
|
||||
repo: &RepositoryRef,
|
||||
maybe_revision: Option<Revision<P>>,
|
||||
maybe_revision: Option<Revision>,
|
||||
maybe_prefix: Option<String>,
|
||||
) -> Result<Tree, Error>
|
||||
where
|
||||
P: ToString,
|
||||
{
|
||||
) -> Result<Tree, Error> {
|
||||
let prefix = maybe_prefix.unwrap_or_default();
|
||||
let rev = match maybe_revision {
|
||||
Some(r) => r,
|
||||
None => Revision::Branch {
|
||||
name: "main".to_string(),
|
||||
peer_id: None,
|
||||
name: refname!("main"),
|
||||
remote: None,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user