Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
Remove `git-url` dependency
Alexis Sellier committed 3 years ago
commit 6f3a598cc168479394b9e88c60ecd427f099f91b
parent 7b7e83fbc75acb7e49315ace7df3278b0eba5dea
5 files changed +29 -60
modified Cargo.lock
@@ -198,16 +198,6 @@ dependencies = [
]

[[package]]
-
name = "bstr"
-
version = "0.2.17"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
-
dependencies = [
-
 "memchr",
-
 "serde",
-
]
-

-
[[package]]
name = "bumpalo"
version = "3.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -524,19 +514,6 @@ dependencies = [
]

[[package]]
-
name = "git-url"
-
version = "0.3.5"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "d9fcc88c679f3dc55e1e4fe0324142abec612cafaafae1bf6a951c324c9d96f8"
-
dependencies = [
-
 "bstr",
-
 "home",
-
 "quick-error",
-
 "serde",
-
 "url",
-
]
-

-
[[package]]
name = "git2"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -593,15 +570,6 @@ dependencies = [
]

[[package]]
-
name = "home"
-
version = "0.5.3"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "2456aef2e6b6a9784192ae780c0f15bc57df0e918585282325e8c8ac27737654"
-
dependencies = [
-
 "winapi",
-
]
-

-
[[package]]
name = "http"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1077,12 +1045,6 @@ dependencies = [
]

[[package]]
-
name = "quick-error"
-
version = "2.0.1"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
-

-
[[package]]
name = "quickcheck"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1121,7 +1083,6 @@ dependencies = [
 "ed25519-compact",
 "fastrand",
 "git-ref-format",
-
 "git-url",
 "git2",
 "log",
 "multibase",
modified radicle-node/src/wire.rs
@@ -46,11 +46,6 @@ pub enum Error {
    InvalidFilterSize(usize),
    #[error(transparent)]
    InvalidRefName(#[from] fmt::Error),
-
    #[error("invalid git url `{url}`: {error}")]
-
    InvalidGitUrl {
-
        url: String,
-
        error: git::url::parse::Error,
-
    },
    #[error("unknown address type `{0}`")]
    UnknownAddressType(u8),
    #[error("unknown message type `{0}`")]
modified radicle/Cargo.toml
@@ -17,7 +17,6 @@ crossbeam-channel = { version = "0.5.6" }
ed25519-compact = { version = "1.0.12", features = ["pem"] }
fastrand = { version = "1.8.0" }
git-ref-format = { version = "0", features = ["serde", "macro"] }
-
git-url = { version = "0.3.5", features = ["serde1"] }
multibase = { version = "0.9.1" }
log = { version = "0.4.17", features = ["std"] }
once_cell = { version = "1.13" }
modified radicle/src/git.rs
@@ -21,7 +21,6 @@ pub use git_ref_format as fmt;
pub use git_ref_format::{
    lit, name, qualified, refname, Component, Namespaced, Qualified, RefStr, RefString,
};
-
pub use git_url as url;
pub use radicle_git_ext as ext;
pub use storage::git::transport::local::Url;
pub use storage::BranchName;
@@ -351,6 +350,29 @@ where
    ))
}

+
/// Git URLs.
+
pub mod url {
+
    use std::path::PathBuf;
+

+
    /// A Git URL using the `file://` scheme.
+
    pub struct File {
+
        pub path: PathBuf,
+
    }
+

+
    impl File {
+
        /// Create a new file URL pointing to the given path.
+
        pub fn new(path: PathBuf) -> Self {
+
            Self { path }
+
        }
+
    }
+

+
    impl ToString for File {
+
        fn to_string(&self) -> String {
+
            format!("file://{}", self.path.display())
+
        }
+
    }
+
}
+

/// Parsing and formatting of commit objects.
/// This module exists to work with commits that have multiple signature headers.
pub mod commit {
modified radicle/src/storage/git.rs
@@ -552,12 +552,9 @@ impl WriteRepository for Repository {
                // TODO: Due to this, I think we'll have to run GC when there is a failure.
                .clone_local(git2::build::CloneLocal::Local)
                .clone(
-
                    &git::url::Url {
-
                        scheme: git::url::Scheme::File,
-
                        path: self.backend.path().to_string_lossy().to_string().into(),
-
                        ..git::url::Url::default()
-
                    }
-
                    .to_string(),
+
                    git::url::File::new(self.backend.path().to_path_buf())
+
                        .to_string()
+
                        .as_str(),
                    &path,
                )?;

@@ -602,14 +599,9 @@ impl WriteRepository for Repository {
        });

        {
-
            let mut remote = self.backend.remote_anonymous(
-
                &git::url::Url {
-
                    scheme: git::url::Scheme::File,
-
                    path: staging.to_string_lossy().to_string().into(),
-
                    ..git::url::Url::default()
-
                }
-
                .to_string(),
-
            )?;
+
            let mut remote = self
+
                .backend
+
                .remote_anonymous(git::url::File::new(staging).to_string().as_str())?;
            let mut opts = git2::FetchOptions::default();
            opts.remote_callbacks(callbacks);