node: Start working on git-fetch

Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
Alexis Sellier
2022-09-13 10:16:04 +02:00
parent 15eed71588
commit 38f4bb52d8
6 changed files with 40 additions and 13 deletions
+24
View File
@@ -0,0 +1,24 @@
use std::net;
use crate::identity::ProjId;
use crate::storage::{Error, WriteStorage};
/// Default port of the `git` transport protocol.
pub const PROTOCOL_PORT: u16 = 9418;
pub fn fetch<S: WriteStorage>(
_proj: &ProjId,
remote: &net::SocketAddr,
mut storage: S,
) -> Result<(), Error> {
let _repo = storage.repository();
let url = format!("git://{}", remote);
let refs: &[&str] = &[];
let mut remote = git2::Remote::create_detached(&url)?;
let mut opts = git2::FetchOptions::default();
remote.fetch(refs, Some(&mut opts), None)?;
Ok(())
}