Radish alpha
r
rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt
Git libraries for Radicle
Radicle
Git
surf: fix path serialization for tree and blob
Fintan Halpenny committed 3 years ago
commit d957f0b1c27bd881e552e270f54cddf7eff8b44d
parent 9df4291
3 files changed +6 -5
modified radicle-surf/src/source/commit.rs
@@ -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.
modified radicle-surf/src/source/object/blob.rs
@@ -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()
    }
}
modified radicle-surf/src/source/object/tree.rs
@@ -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()