mirror of
https://seed.radicle.dev/rad:z4D5UCArafTzTQpDZNQRuqswh3ury.git
synced 2026-10-18 19:10:45 +08:00
Remove redundant surf Oid conversions
radicle-surf 0.29 switched from radicle-git-ext to radicle-oid for
its Oid type, making radicle_surf::Oid and radicle::git::Oid the
same type. The crate::oid::{from_surf, into_surf} helpers were
therefore no-op round-trips through git2::Oid.
This commit is contained in:
@@ -152,7 +152,7 @@ pub struct DiffFile {
|
||||
impl From<surf::diff::DiffFile> for DiffFile {
|
||||
fn from(value: surf::diff::DiffFile) -> Self {
|
||||
Self {
|
||||
oid: crate::oid::from_surf(value.oid),
|
||||
oid: value.oid,
|
||||
mode: value.mode.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -241,16 +241,12 @@ pub struct RepoRefs {
|
||||
impl From<surf::Commit> 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ impl Blob {
|
||||
impl<T: AsRef<[u8]>> From<surf::blob::Blob<T>> for Blob {
|
||||
fn from(blob: surf::blob::Blob<T>) -> Self {
|
||||
Blob::new(
|
||||
crate::oid::from_surf(blob.object_id()),
|
||||
blob.object_id(),
|
||||
blob.is_binary(),
|
||||
blob.commit().clone().into(),
|
||||
blob.content(),
|
||||
|
||||
@@ -23,16 +23,12 @@ pub struct Commit {
|
||||
impl From<surf::Commit> 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::<Vec<_>>(),
|
||||
parents: commit.parents,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -716,8 +716,8 @@ impl ToPretty for surf::diff::Moved {
|
||||
type Context = ();
|
||||
|
||||
fn pretty<R: Repo>(&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<R: Repo>(&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<R: Repo>(&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<R: Repo>(&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<R: Repo>(&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 {
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user