diff options
-rw-r--r-- | Cargo.lock | 68 | ||||
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/git.rs | 32 | ||||
-rw-r--r-- | src/lib.rs | 1 | ||||
-rw-r--r-- | src/main.rs | 8 |
5 files changed, 107 insertions, 3 deletions
@@ -35,6 +35,9 @@ name = "cc" version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" +dependencies = [ + "jobserver", +] [[package]] name = "cfg-if" @@ -159,6 +162,21 @@ dependencies = [ ] [[package]] +name = "git2" +version = "0.13.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9831e983241f8c5591ed53f17d874833e2fa82cac2625f3888c50cbfe136cba" +dependencies = [ + "bitflags", + "libc", + "libgit2-sys", + "log", + "openssl-probe", + "openssl-sys", + "url", +] + +[[package]] name = "h2" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -297,6 +315,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] +name = "jobserver" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "972f5ae5d1cb9c6ae417789196c803205313edde988685da5e3aae0827b9e7fd" +dependencies = [ + "libc", +] + +[[package]] name = "js-sys" version = "0.3.51" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -318,6 +345,46 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36" [[package]] +name = "libgit2-sys" +version = "0.12.21+1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86271bacd72b2b9e854c3dcfb82efd538f15f870e4c11af66900effb462f6825" +dependencies = [ + "cc", + "libc", + "libssh2-sys", + "libz-sys", + "openssl-sys", + "pkg-config", +] + +[[package]] +name = "libssh2-sys" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0186af0d8f171ae6b9c4c90ec51898bad5d08a2d5e470903a50d9ad8959cbee" +dependencies = [ + "cc", + "libc", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "libz-sys" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] name = "log" version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -563,6 +630,7 @@ dependencies = [ name = "reflectub" version = "0.0.1" dependencies = [ + "git2", "reqwest", "serde", ] @@ -4,5 +4,6 @@ version = "0.0.1" edition = "2018" [dependencies] +git2 = "0.13.20" reqwest = { version = "0.11.3", features = ["blocking", "json"] } serde = { version = "1.0.126", features = ["derive"] } diff --git a/src/git.rs b/src/git.rs new file mode 100644 index 0000000..d58da3c --- /dev/null +++ b/src/git.rs @@ -0,0 +1,32 @@ +use std::path::Path; + + +pub fn mirror() -> Result<(), Box<dyn std::error::Error>> { + // let builder = git2::build::RepoBuilder::new() + // .bare(true) + // .clone( + // "https://github.com/teddywing/google-calendar-rsvp.git", + // Path::new("/tmp/grsvp"), + // ); + + let repo = git2::Repository::init_bare(Path::new("/tmp/grsvp"))?; + + let remote_name = "origin"; + + let mut remote = repo.remote_with_fetch( + remote_name, + "https://github.com/teddywing/google-calendar-rsvp.git", + "+refs/*:refs/*", + )?; + + let mut config = repo.config()?; + config.set_bool( + &format!("remote.{}.mirror", remote_name), + true, + )?; + + let refspecs: [&str; 0] = []; + remote.fetch(&refspecs, None, None)?; + + Ok(()) +} @@ -1,2 +1,3 @@ +pub mod git; pub mod github; pub mod repo; diff --git a/src/main.rs b/src/main.rs index ea540e6..994c86f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,10 @@ -use reflectub::github; +use reflectub::{git, github}; fn main() { - let repos = github::fetch_repos().unwrap(); + // let repos = github::fetch_repos().unwrap(); + // + // dbg!(&repos); - dbg!(&repos); + git::mirror().unwrap(); } |