diff --git a/crates/radicle-types/src/diff.rs b/crates/radicle-types/src/diff.rs index d1860ef8d..e2d2686e1 100644 --- a/crates/radicle-types/src/diff.rs +++ b/crates/radicle-types/src/diff.rs @@ -152,7 +152,7 @@ pub struct DiffFile { impl From for DiffFile { fn from(value: surf::diff::DiffFile) -> Self { Self { - oid: crate::oid::from_surf(value.oid), + oid: value.oid, mode: value.mode.into(), } } diff --git a/crates/radicle-types/src/lib.rs b/crates/radicle-types/src/lib.rs index 631d20f14..a610210f5 100644 --- a/crates/radicle-types/src/lib.rs +++ b/crates/radicle-types/src/lib.rs @@ -11,7 +11,6 @@ pub mod config; pub mod diff; pub mod domain; pub mod error; -pub mod oid; pub mod outbound; pub mod repo; pub mod source; diff --git a/crates/radicle-types/src/oid.rs b/crates/radicle-types/src/oid.rs deleted file mode 100644 index 8231245fc..000000000 --- a/crates/radicle-types/src/oid.rs +++ /dev/null @@ -1,10 +0,0 @@ -// `radicle_surf::Oid` and `radicle::git::Oid` are both aliases for -// `radicle_oid::Oid`, so these conversions are identities. They are kept as a -// single boundary in case the two crates diverge on their Oid type again. -pub(crate) fn from_surf(oid: radicle_surf::Oid) -> radicle::git::Oid { - oid -} - -pub(crate) fn into_surf(oid: radicle::git::Oid) -> radicle_surf::Oid { - oid -} diff --git a/crates/radicle-types/src/repo.rs b/crates/radicle-types/src/repo.rs index 3e56c2a4d..1dd4ac0dc 100644 --- a/crates/radicle-types/src/repo.rs +++ b/crates/radicle-types/src/repo.rs @@ -241,16 +241,12 @@ pub struct RepoRefs { impl From for Commit { fn from(value: surf::Commit) -> Self { Self { - id: crate::oid::from_surf(value.id), + id: value.id, author: value.author, committer: value.committer, message: value.message, summary: value.summary, - parents: value - .parents - .into_iter() - .map(crate::oid::from_surf) - .collect(), + parents: value.parents, } } } diff --git a/crates/radicle-types/src/source/blob.rs b/crates/radicle-types/src/source/blob.rs index d67bd7019..b10736fb2 100644 --- a/crates/radicle-types/src/source/blob.rs +++ b/crates/radicle-types/src/source/blob.rs @@ -54,7 +54,7 @@ impl Blob { impl> From> for Blob { fn from(blob: surf::blob::Blob) -> Self { Blob::new( - crate::oid::from_surf(blob.object_id()), + blob.object_id(), blob.is_binary(), blob.commit().clone().into(), blob.content(), diff --git a/crates/radicle-types/src/source/commit.rs b/crates/radicle-types/src/source/commit.rs index 4dbeae9a9..f22412220 100644 --- a/crates/radicle-types/src/source/commit.rs +++ b/crates/radicle-types/src/source/commit.rs @@ -23,16 +23,12 @@ pub struct Commit { impl From for Commit { fn from(commit: surf::Commit) -> Self { Commit { - id: crate::oid::from_surf(commit.id), + id: commit.id, author: commit.author, committer: commit.committer, message: commit.message.to_string(), summary: commit.summary.to_string(), - parents: commit - .parents - .into_iter() - .map(crate::oid::from_surf) - .collect::>(), + parents: commit.parents, } } } diff --git a/crates/radicle-types/src/source/tree.rs b/crates/radicle-types/src/source/tree.rs index 99ff36f98..aa69d8a1a 100644 --- a/crates/radicle-types/src/source/tree.rs +++ b/crates/radicle-types/src/source/tree.rs @@ -21,7 +21,7 @@ pub struct Tree { impl Tree { pub fn from_surf(tree: surf::tree::Tree, path: &std::path::Path) -> Self { Tree { - id: crate::oid::from_surf(tree.object_id()), + id: tree.object_id(), path: path.to_path_buf(), entries: tree .entries() @@ -76,9 +76,9 @@ impl Entry { impl Entry { pub fn object_id(&self) -> Oid { match self.kind { - surf::tree::EntryKind::Blob(id) => crate::oid::from_surf(id), - surf::tree::EntryKind::Tree(id) => crate::oid::from_surf(id), - surf::tree::EntryKind::Submodule { id, .. } => crate::oid::from_surf(id), + surf::tree::EntryKind::Blob(id) => id, + surf::tree::EntryKind::Tree(id) => id, + surf::tree::EntryKind::Submodule { id, .. } => id, } } } diff --git a/crates/radicle-types/src/syntax.rs b/crates/radicle-types/src/syntax.rs index e014a2363..94bc4d198 100644 --- a/crates/radicle-types/src/syntax.rs +++ b/crates/radicle-types/src/syntax.rs @@ -716,8 +716,8 @@ impl ToPretty for surf::diff::Moved { type Context = (); fn pretty(&self, hi: &Highlighter, _: &Self::Context, repo: &R) -> Self::Output { - let old = Some((self.old_path.as_path(), crate::oid::from_surf(self.old.oid))); - let new = Some((self.new_path.as_path(), crate::oid::from_surf(self.new.oid))); + let old = Some((self.old_path.as_path(), self.old.oid)); + let new = Some((self.new_path.as_path(), self.new.oid)); let blobs = Blobs::from_paths(old, new, repo); types::diff::Moved { @@ -736,7 +736,7 @@ impl ToPretty for surf::diff::Added { fn pretty(&self, hi: &Highlighter, _: &Self::Context, repo: &R) -> Self::Output { let old = None; - let new = Some((self.path.as_path(), crate::oid::from_surf(self.new.oid))); + let new = Some((self.path.as_path(), self.new.oid)); let blobs = Blobs::from_paths(old, new, repo); types::diff::Added { @@ -752,7 +752,7 @@ impl ToPretty for surf::diff::Deleted { type Context = (); fn pretty(&self, hi: &Highlighter, _: &Self::Context, repo: &R) -> Self::Output { - let old = Some((self.path.as_path(), crate::oid::from_surf(self.old.oid))); + let old = Some((self.path.as_path(), self.old.oid)); let new = None; let blobs = Blobs::from_paths(old, new, repo); @@ -769,8 +769,8 @@ impl ToPretty for surf::diff::Modified { type Context = (); fn pretty(&self, hi: &Highlighter, _: &Self::Context, repo: &R) -> Self::Output { - let old = Some((self.path.as_path(), crate::oid::from_surf(self.old.oid))); - let new = Some((self.path.as_path(), crate::oid::from_surf(self.new.oid))); + let old = Some((self.path.as_path(), self.old.oid)); + let new = Some((self.path.as_path(), self.new.oid)); let blobs = Blobs::from_paths(old, new, repo); types::diff::Modified { @@ -787,8 +787,8 @@ impl ToPretty for surf::diff::Copied { type Context = (); fn pretty(&self, hi: &Highlighter, _: &Self::Context, repo: &R) -> Self::Output { - let old = Some((self.old_path.as_path(), crate::oid::from_surf(self.old.oid))); - let new = Some((self.new_path.as_path(), crate::oid::from_surf(self.new.oid))); + let old = Some((self.old_path.as_path(), self.old.oid)); + let new = Some((self.new_path.as_path(), self.new.oid)); let blobs = Blobs::from_paths(old, new, repo); types::diff::Copied { diff --git a/crates/radicle-types/src/traits/repo.rs b/crates/radicle-types/src/traits/repo.rs index 1010ac7f0..6606dcf90 100644 --- a/crates/radicle-types/src/traits/repo.rs +++ b/crates/radicle-types/src/traits/repo.rs @@ -182,9 +182,9 @@ fn last_path_commit( }); let commit = match fast { - Some(oid) => surf_repo.commit(crate::oid::into_surf(oid))?, + Some(oid) => surf_repo.commit(oid)?, None => surf_repo - .last_commit(&path, crate::oid::into_surf(head))? + .last_commit(&path, head)? .ok_or_else(|| git2::Error::from_str("no commit found for path"))?, }; @@ -548,7 +548,7 @@ pub trait Repo: Profile { Some(sha) => sha, None => resolve_revision(&storage_repo, peer, revision)?, }; - let tree = repo.tree(crate::oid::into_surf(oid), &path)?; + let tree = repo.tree(oid, &path)?; Ok(source::tree::Tree::from_surf(tree, &path)) } @@ -565,7 +565,7 @@ pub trait Repo: Profile { let oid = match sha { Some(sha) => sha, - None => crate::oid::from_surf(surf_repo.head()?), + None => surf_repo.head()?, }; // Resolve the blob via a direct tree lookup. `surf::Repository::blob` @@ -642,8 +642,8 @@ pub trait Repo: Profile { } let repo = radicle_surf::Repository::open(&repo_path)?; - let base = repo.commit(crate::oid::into_surf(base))?; - let commit = repo.commit(crate::oid::into_surf(head))?; + let base = repo.commit(base)?; + let commit = repo.commit(head)?; let diff = repo.diff(base.id, commit.id)?; let stats = diff.stats(); @@ -830,8 +830,7 @@ pub trait Repo: Profile { }; let repo = surf::Repository::open(storage_repo.path())?; - let head = crate::oid::into_surf(oid); - let commits = repo.history(head)?; + let commits = repo.history(oid)?; let cursor = skip.unwrap_or(0); match take { @@ -927,7 +926,7 @@ pub trait Repo: Profile { }; let repo = surf::Repository::open(storage_repo.path())?; - let commit = repo.commit(crate::oid::into_surf(oid))?; + let commit = repo.commit(oid)?; Ok(commit.into()) }