mirror of
https://seed.radicle.dev/rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt.git
synced 2026-10-31 08:50:45 +08:00
surf: fix path serialization for tree and blob
The http-api code expects the 'path' serialized field to be the full path for trees, tree entries, and blobs, i.e. the path where it is located concatenated with the name of the entry. Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
@@ -47,7 +47,7 @@ pub struct Commit {
|
||||
}
|
||||
|
||||
/// Representation of a code commit.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Header {
|
||||
/// Identifier of the commit in the form of a sha1 hash. Often referred to
|
||||
/// as oid or object id.
|
||||
|
||||
@@ -103,7 +103,7 @@ impl Serialize for Blob {
|
||||
state.serialize_field("content", &self.content)?;
|
||||
state.serialize_field("lastCommit", &self.commit)?;
|
||||
state.serialize_field("name", &self.file.name())?;
|
||||
state.serialize_field("path", &self.file.location())?;
|
||||
state.serialize_field("path", &self.file.path())?;
|
||||
state.end()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ use crate::{
|
||||
};
|
||||
|
||||
/// Result of a directory listing, carries other trees and blobs.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Tree {
|
||||
pub directory: Directory,
|
||||
pub commit: Option<commit::Header>,
|
||||
@@ -95,7 +96,7 @@ impl Serialize for Tree {
|
||||
state.serialize_field("entries", &self.entries)?;
|
||||
state.serialize_field("lastCommit", &self.commit)?;
|
||||
state.serialize_field("name", &self.directory.name())?;
|
||||
state.serialize_field("path", &self.directory.location())?;
|
||||
state.serialize_field("path", &self.directory.path())?;
|
||||
state.end()
|
||||
}
|
||||
}
|
||||
@@ -126,14 +127,14 @@ impl Serialize for TreeEntry {
|
||||
{
|
||||
const FIELDS: usize = 4;
|
||||
let mut state = serializer.serialize_struct("TreeEntry", FIELDS)?;
|
||||
state.serialize_field("path", &self.entry.location())?;
|
||||
state.serialize_field("path", &self.entry.path())?;
|
||||
state.serialize_field("name", &self.entry.name())?;
|
||||
state.serialize_field("lastCommit", &None::<commit::Header>)?;
|
||||
state.serialize_field(
|
||||
"kind",
|
||||
match self.entry {
|
||||
directory::Entry::File(_) => "blob",
|
||||
directory::Entry::Directory(_) => "directory",
|
||||
directory::Entry::Directory(_) => "tree",
|
||||
},
|
||||
)?;
|
||||
state.end()
|
||||
|
||||
Reference in New Issue
Block a user