Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
workspace: Remove dependency `radicle-git-ext`
Lorenz Leutgeb committed 7 months ago
commit 190c37853390c28ffa4e2ef0a6beb15d23ac7eba
parent b0df7d409767066f816a9b3e1c056c309bb8a7b5
14 files changed +34 -101
modified Cargo.lock
@@ -2951,7 +2951,6 @@ dependencies = [
name = "radicle-git2-metadata"
version = "0.1.0"
dependencies = [
-
 "git2",
 "thiserror 1.0.69",
]

@@ -3003,7 +3002,6 @@ dependencies = [
 "git2",
 "gix-hash",
 "qcheck",
-
 "radicle-git-ext",
 "radicle-git-ref-format",
 "schemars",
 "serde",
modified Cargo.toml
@@ -69,12 +69,11 @@ winpipe = "0.1.1"
zeroize = "1.5.7"

# Crates from the "radicle-git" workspace. These should be synced manually.
-
# When updating, start from `radicle-surf`, which depends on the others:
+
# When updating, start from `radicle-surf`:
# `radicle-surf` → `radicle-git-ext` → `git-ref-format` → `git-ref-format-core`
# Also note that `radicle-surf → git2` and `radicle-git-ext` → `git2`, so try
# to also sync with `git2` if possible.
git-ref-format-core = { version = "0.5.0", default-features = false }
-
radicle-git-ext = { version = "0.10.0", default-features = false }
radicle-surf = "0.25.0"

[workspace.lints]
modified crates/radicle-cli/Cargo.toml
@@ -24,7 +24,7 @@ lexopt = { workspace = true }
localtime = { workspace = true }
log = { workspace = true, features = ["std"] }
nonempty = { workspace = true }
-
radicle = { workspace = true, features = ["logger", "schemars", "radicle-git-ext"] }
+
radicle = { workspace = true, features = ["logger", "schemars"] }
radicle-cob = { workspace = true }
radicle-crypto = { workspace = true }
radicle-git-ref-format = { workspace = true, features = ["macro"] }
modified crates/radicle-cli/src/commands/patch/review/builder.rs
@@ -197,24 +197,24 @@ impl ReviewItem {

    fn paths(&self) -> (Option<(&Path, Oid)>, Option<(&Path, Oid)>) {
        match self {
-
            Self::FileAdded { path, new, .. } => (None, Some((path, new.oid.into()))),
-
            Self::FileDeleted { path, old, .. } => (Some((path, old.oid.into())), None),
+
            Self::FileAdded { path, new, .. } => (None, Some((path, Oid::from(*new.oid)))),
+
            Self::FileDeleted { path, old, .. } => (Some((path, Oid::from(*old.oid))), None),
            Self::FileMoved { moved } => (
-
                Some((&moved.old_path, moved.old.oid.into())),
-
                Some((&moved.new_path, moved.new.oid.into())),
+
                Some((&moved.old_path, Oid::from(*moved.old.oid))),
+
                Some((&moved.new_path, Oid::from(*moved.new.oid))),
            ),
            Self::FileCopied { copied } => (
-
                Some((&copied.old_path, copied.old.oid.into())),
-
                Some((&copied.new_path, copied.new.oid.into())),
+
                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, old.oid.into())), Some((path, new.oid.into())))
+
                (Some((path, Oid::from(*old.oid))), Some((path, Oid::from(*new.oid))))
            }
            Self::FileEofChanged { path, old, new, .. } => {
-
                (Some((path, old.oid.into())), Some((path, new.oid.into())))
+
                (Some((path, Oid::from(*old.oid))), Some((path, Oid::from(*new.oid))))
            }
            Self::FileModeChanged { path, old, new, .. } => {
-
                (Some((path, old.oid.into())), Some((path, new.oid.into())))
+
                (Some((path, Oid::from(*old.oid))), Some((path, Oid::from(*new.oid))))
            }
        }
    }
modified crates/radicle-cli/src/git/pretty_diff.rs
@@ -339,7 +339,7 @@ impl ToPretty for Added {
        repo: &R,
    ) -> Self::Output {
        let old = None;
-
        let new = Some((self.path.as_path(), self.new.oid.into()));
+
        let new = Some((self.path.as_path(), Oid::from(*self.new.oid)));

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

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

        pretty_modification(header, &self.diff, old, new, repo, hi)
    }
modified crates/radicle-cli/src/git/unified_diff.rs
@@ -307,8 +307,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 {
@@ -316,8 +316,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)
                    ))?;
                }

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

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

modified crates/radicle-cob/Cargo.toml
@@ -18,7 +18,6 @@ default = []
# Only used for testing. Ensures that commit ids are stable.
stable-commit-ids = []
test = []
-
git2 = ["radicle-git2-metadata/git2", "dep:git2"]

[dependencies]
fastrand = { workspace = true }
modified crates/radicle-cob/src/backend/git/change.rs
@@ -294,7 +294,15 @@ fn write_commit(
            .map_err(signatures::error::Signatures::from)?
            .as_str(),
    );
-
    let author = Author::try_from(&author)?;
+

+
    let author = Author {
+
        name: String::from_utf8(author.name_bytes().to_vec())?,
+
        email: String::from_utf8(author.email_bytes().to_vec())?,
+
        time: {
+
            let when = author.when();
+
            metadata::author::Time::new(when.seconds(), when.offset_minutes())
+
        },
+
    };

    #[cfg(feature = "stable-commit-ids")]
    // Ensures the commit id doesn't change on every run.
modified crates/radicle-git2-metadata/Cargo.toml
@@ -10,5 +10,4 @@ keywords = ["radicle", "git", "metadata"]
rust-version.workspace = true

[dependencies]
-
thiserror = { workspace = true }
-
git2 = { workspace = true, optional = true, default-features = false }

\ No newline at end of file
+
thiserror = { workspace = true }

\ No newline at end of file
modified crates/radicle-git2-metadata/src/author.rs
@@ -77,22 +77,6 @@ impl FromStr for Time {
    }
}

-
/*
-
#[cfg(feature = "git2")]
-
impl From<Time> for git2::Time {
-
    fn from(t: Time) -> Self {
-
        Self::new(t.seconds, t.offset)
-
    }
-
}
-

-
#[cfg(feature = "git2")]
-
impl From<git2::Time> for Time {
-
    fn from(t: git2::Time) -> Self {
-
        Self::new(t.seconds(), t.offset_minutes())
-
    }
-
}
-
*/
-

impl fmt::Display for Time {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        let sign = if self.offset.is_negative() { '-' } else { '+' };
@@ -108,32 +92,6 @@ impl fmt::Display for Author {
    }
}

-
#[cfg(feature = "git2")]
-
impl TryFrom<&Author> for git2::Signature<'_> {
-
    type Error = git2::Error;
-

-
    fn try_from(person: &Author) -> Result<Self, Self::Error> {
-
        let time = git2::Time::new(person.time.seconds, person.time.offset);
-
        git2::Signature::new(&person.name, &person.email, &time)
-
    }
-
}
-

-
#[cfg(feature = "git2")]
-
impl<'a> TryFrom<&git2::Signature<'a>> for Author {
-
    type Error = str::Utf8Error;
-

-
    fn try_from(value: &git2::Signature<'a>) -> Result<Self, Self::Error> {
-
        Ok(Self {
-
            name: str::from_utf8(value.name_bytes())?.to_string(),
-
            email: str::from_utf8(value.email_bytes())?.to_string(),
-
            time: {
-
                let when = value.when();
-
                Time::new(when.seconds(), when.offset_minutes())
-
            },
-
        })
-
    }
-
}
-

#[derive(Debug, Error)]
pub enum ParseError {
    #[error("missing '{0}' while parsing person signature")]
modified crates/radicle-git2-metadata/src/commit.rs
@@ -126,12 +126,12 @@ impl<Tree, Parent> CommitData<Tree, Parent> {
        })
    }

-
    /// Convert the `CommitData::parents` into a vector containing
+
    /// Convert the [`CommitData::parents`] into a vector containing
    /// values of type `U`. The conversion function `f` can be
    /// fallible.
    ///
-
    /// For example, `map_parents` can be used to resolve the `Oid`s
-
    /// to their respective `git2::Commit`s.
+
    /// For example, this can be used to resolve the object identifiers
+
    /// to their respective full commits.
    pub fn map_parents<U, E, F>(self, f: F) -> Result<CommitData<Tree, U>, E>
    where
        F: FnMut(Parent) -> Result<U, E>,
modified crates/radicle-oid/Cargo.toml
@@ -14,13 +14,11 @@ rust-version.workspace = true
default = ["std"]
gix = ["dep:gix-hash"]
std = []
-
radicle-git-ext = ["git2", "dep:radicle-git-ext"]

[dependencies]
git2 = { workspace = true, optional = true, default-features = false }
gix-hash = { version = "0.15.1", optional = true, default-features = false }
qcheck = { workspace = true, optional = true, default-features = false }
-
radicle-git-ext = { workspace = true, optional = true, default-features = false }
radicle-git-ref-format = { workspace = true, optional = true, default-features = false }
schemars = { workspace = true, optional = true, default-features = false }
serde = { workspace = true, optional = true, default-features = false }

\ No newline at end of file
modified crates/radicle-oid/src/lib.rs
@@ -46,12 +46,6 @@
//!
//! Implementions of [`Serialize`] and [`Deserialize`].
//!
-
//! ### `radicle-git-ext`
-
//!
-
//! [`radicle_git_ext::Oid`]: ::radicle_git_ext::Oid
-
//!
-
//! Deprecated conversion to/from [`radicle_git_ext::Oid`].
-
//!
//! ### `qcheck`
//!
//! [`qcheck::Arbitrary`]: ::qcheck::Arbitrary
@@ -315,25 +309,6 @@ mod git2 {
    }
}

-
/// Deprecated!
-
#[cfg(feature = "radicle-git-ext")]
-
mod radicle_git_ext {
-
    use super::Oid;
-
    use ::radicle_git_ext::Oid as Other;
-

-
    impl From<Other> for Oid {
-
        fn from(other: Other) -> Self {
-
            Oid::from(::git2::Oid::from(other))
-
        }
-
    }
-

-
    impl From<Oid> for Other {
-
        fn from(oid: Oid) -> Other {
-
            Other::from(<::git2::Oid>::from(oid))
-
        }
-
    }
-
}
-

#[cfg(feature = "qcheck")]
mod qcheck {
    use super::*;
modified crates/radicle/Cargo.toml
@@ -14,7 +14,6 @@ default = []
test = ["qcheck", "radicle-crypto/test", "radicle-cob/test"]
logger = ["colored", "chrono"]
schemars = ["radicle-oid/schemars", "dep:schemars"]
-
radicle-git-ext = ["radicle-oid/radicle-git-ext"]

[dependencies]
amplify = { workspace = true, features = ["std"] }