Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
remote-helper: create GitService trait
Adrian Duke committed 2 months ago
commit 1414f84ff9644624ea7caf2c0ce150de1e84f5fd
parent d6499a1273c9ab266a3ff1e86030d6a53c790bf4
1 file changed +48 -0
added crates/radicle-remote-helper/src/service.rs
@@ -0,0 +1,48 @@
+
use std::io;
+
use std::path::Path;
+
use std::process;
+

+
use radicle::git;
+
use radicle::storage;
+

+
/// Abstraction for Git subprocess calls.
+
pub trait GitService {
+
    /// Run `git fetch-pack`.
+
    fn fetch_pack(
+
        &self,
+
        working: Option<&Path>,
+
        stored: &storage::git::Repository,
+
        oids: Vec<git::Oid>,
+
        verbosity: git::Verbosity,
+
    ) -> io::Result<process::Output>;
+

+
    /// Run `git send-pack` (via `radicle::git::run`).
+
    fn send_pack(
+
        &self,
+
        working: Option<&Path>,
+
        args: &[String],
+
    ) -> io::Result<process::Output>;
+
}
+

+
/// Production implementation using real Git subprocesses.
+
pub struct RealGitService;
+

+
impl GitService for RealGitService {
+
    fn fetch_pack(
+
        &self,
+
        working: Option<&Path>,
+
        stored: &storage::git::Repository,
+
        oids: Vec<git::Oid>,
+
        verbosity: git::Verbosity,
+
    ) -> io::Result<process::Output> {
+
        git::process::fetch_pack(working, stored, oids, verbosity)
+
    }
+

+
    fn send_pack(
+
        &self,
+
        working: Option<&Path>,
+
        args: &[String],
+
    ) -> io::Result<process::Output> {
+
        git::run(working, args)
+
    }
+
}