Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle-cli: Adjust OID types
Lorenz Leutgeb committed 3 months ago
commit ed6a823274ce792ae0ab55b3700bcaabdcdce837
parent 60827792f673eb2fd14c08a52f1b0e17125ede6e
3 files changed +25 -28
modified crates/radicle-cli/src/commands/patch/review/builder.rs
@@ -196,28 +196,25 @@ impl ReviewItem {

    fn paths(&self) -> (Option<(&Path, Oid)>, Option<(&Path, Oid)>) {
        match self {
-
            Self::FileAdded { path, new, .. } => (None, Some((path, Oid::from(*new.oid)))),
-
            Self::FileDeleted { path, old, .. } => (Some((path, Oid::from(*old.oid))), None),
+
            Self::FileAdded { path, new, .. } => (None, Some((path, new.oid))),
+
            Self::FileDeleted { path, old, .. } => (Some((path, old.oid)), None),
            Self::FileMoved { moved } => (
-
                Some((&moved.old_path, Oid::from(*moved.old.oid))),
-
                Some((&moved.new_path, Oid::from(*moved.new.oid))),
+
                Some((&moved.old_path, moved.old.oid)),
+
                Some((&moved.new_path, moved.new.oid)),
            ),
            Self::FileCopied { copied } => (
-
                Some((&copied.old_path, Oid::from(*copied.old.oid))),
-
                Some((&copied.new_path, Oid::from(*copied.new.oid))),
-
            ),
-
            Self::FileModified { path, old, new, .. } => (
-
                Some((path, Oid::from(*old.oid))),
-
                Some((path, Oid::from(*new.oid))),
-
            ),
-
            Self::FileEofChanged { path, old, new, .. } => (
-
                Some((path, Oid::from(*old.oid))),
-
                Some((path, Oid::from(*new.oid))),
-
            ),
-
            Self::FileModeChanged { path, old, new, .. } => (
-
                Some((path, Oid::from(*old.oid))),
-
                Some((path, Oid::from(*new.oid))),
+
                Some((&copied.old_path, copied.old.oid)),
+
                Some((&copied.new_path, copied.new.oid)),
            ),
+
            Self::FileModified { path, old, new, .. } => {
+
                (Some((path, old.oid)), Some((path, new.oid)))
+
            }
+
            Self::FileEofChanged { path, old, new, .. } => {
+
                (Some((path, old.oid)), Some((path, new.oid)))
+
            }
+
            Self::FileModeChanged { path, old, new, .. } => {
+
                (Some((path, old.oid)), Some((path, new.oid)))
+
            }
        }
    }

modified crates/radicle-cli/src/git/pretty_diff.rs
@@ -338,7 +338,7 @@ impl ToPretty for Added {
        repo: &R,
    ) -> Self::Output {
        let old = None;
-
        let new = Some((self.path.as_path(), Oid::from(*self.new.oid)));
+
        let new = Some((self.path.as_path(), self.new.oid));

        pretty_modification(header, &self.diff, old, new, repo, hi)
    }
@@ -354,7 +354,7 @@ impl ToPretty for Deleted {
        header: &Self::Context,
        repo: &R,
    ) -> Self::Output {
-
        let old = Some((self.path.as_path(), Oid::from(*self.old.oid)));
+
        let old = Some((self.path.as_path(), self.old.oid));
        let new = None;

        pretty_modification(header, &self.diff, old, new, repo, hi)
@@ -371,8 +371,8 @@ impl ToPretty for Modified {
        header: &Self::Context,
        repo: &R,
    ) -> Self::Output {
-
        let old = Some((self.path.as_path(), Oid::from(*self.old.oid)));
-
        let new = Some((self.path.as_path(), Oid::from(*self.new.oid)));
+
        let old = Some((self.path.as_path(), self.old.oid));
+
        let new = Some((self.path.as_path(), self.new.oid));

        pretty_modification(header, &self.diff, old, new, repo, hi)
    }
modified crates/radicle-cli/src/git/unified_diff.rs
@@ -306,8 +306,8 @@ impl Encode for FileHeader {
                if old.mode == new.mode {
                    w.meta(format!(
                        "index {}..{} {:o}",
-
                        term::format::oid(*old.oid),
-
                        term::format::oid(*new.oid),
+
                        term::format::oid(old.oid),
+
                        term::format::oid(new.oid),
                        u32::from(old.mode.clone()),
                    ))?;
                } else {
@@ -315,8 +315,8 @@ impl Encode for FileHeader {
                    w.meta(format!("new mode {:o}", u32::from(new.mode.clone())))?;
                    w.meta(format!(
                        "index {}..{}",
-
                        term::format::oid(*old.oid),
-
                        term::format::oid(*new.oid)
+
                        term::format::oid(old.oid),
+
                        term::format::oid(new.oid)
                    ))?;
                }

@@ -334,7 +334,7 @@ impl Encode for FileHeader {
                w.meta(format!(
                    "index {}..{}",
                    term::format::oid(git::Oid::sha1_zero()),
-
                    term::format::oid(*new.oid),
+
                    term::format::oid(new.oid),
                ))?;

                w.meta("--- /dev/null")?;
@@ -354,7 +354,7 @@ impl Encode for FileHeader {
                ))?;
                w.meta(format!(
                    "index {}..{}",
-
                    term::format::oid(*old.oid),
+
                    term::format::oid(old.oid),
                    term::format::oid(git::Oid::sha1_zero())
                ))?;