Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
REVIEW: use method instead of `TryFrom`
✗ CI failure Fintan Halpenny committed 2 months ago
commit b89ecdf976ebacc043de503a8219f3a81979c8a0
parent 5be1e5ae50f54f13b1c91997d5270fd5a2424a5f
1 failed (1 total) View logs
2 files changed +7 -9
modified crates/radicle-node/src/worker.rs
@@ -176,7 +176,7 @@ impl Worker {
                    Some(Ok(Ok(header))) => header,
                };

-
                let Ok(header) = upload_pack::GitRequest::try_from(header) else {
+
                let Some(header) = upload_pack::GitRequest::from_packetline(header) else {
                    return FetchResult::Responder {
                        rid: None,
                        result: Err(UploadError::PacketLine(std::io::Error::new(
modified crates/radicle-node/src/worker/upload_pack.rs
@@ -255,6 +255,12 @@ pub struct GitRequest {
}

impl GitRequest {
+
    pub(super) fn from_packetline(
+
        packet_line: gix_packetline::PacketLineRef<'_>,
+
    ) -> Option<GitRequest> {
+
        packet_line.as_slice().and_then(Self::parse)
+
    }
+

    /// Parse a Git command from a packet-line.
    fn parse(input: &[u8]) -> Option<Self> {
        let input = std::str::from_utf8(input).ok()?;
@@ -293,11 +299,3 @@ impl GitRequest {
        })
    }
}
-

-
impl TryFrom<gix_packetline::PacketLineRef<'_>> for GitRequest {
-
    type Error = ();
-

-
    fn try_from(value: gix_packetline::PacketLineRef<'_>) -> Result<Self, Self::Error> {
-
        value.as_slice().and_then(Self::parse).ok_or(())
-
    }
-
}