feat: build with ssh

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2023-06-25 20:40:12 +02:00
parent f8035357b7
commit 6a82e0c10a
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912
3 changed files with 23 additions and 1 deletions

15
Cargo.lock generated
View File

@ -1223,11 +1223,26 @@ checksum = "a80df2e11fb4a61f4ba2ab42dbe7f74468da143f1a75c74e11dee7c813f694fa"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",
"libssh2-sys",
"libz-sys", "libz-sys",
"openssl-sys", "openssl-sys",
"pkg-config", "pkg-config",
] ]
[[package]]
name = "libssh2-sys"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dc8a030b787e2119a731f1951d6a773e2280c660f8ec4b0f5e1505a386e71ee"
dependencies = [
"cc",
"libc",
"libz-sys",
"openssl-sys",
"pkg-config",
"vcpkg",
]
[[package]] [[package]]
name = "libz-sys" name = "libz-sys"
version = "1.1.9" version = "1.1.9"

View File

@ -18,6 +18,7 @@ walkdir = "2.3.2"
git2 = { version = "0.17.2", default-features = false, features = [ git2 = { version = "0.17.2", default-features = false, features = [
"vendored-libgit2", "vendored-libgit2",
"vendored-openssl", "vendored-openssl",
"ssh",
] } ] }
clap = { version = "4.3.4", features = ["env", "string"] } clap = { version = "4.3.4", features = ["env", "string"] }
envconfig = "0.10.0" envconfig = "0.10.0"

View File

@ -1,11 +1,15 @@
use std::{ use std::{
env::{self, current_dir}, env::{self, current_dir},
ffi::OsStr, ffi::OsStr,
io::Write,
path::{Path, PathBuf}, path::{Path, PathBuf},
sync::{Arc, Mutex}, sync::{Arc, Mutex},
}; };
use git2::{build::RepoBuilder, FetchOptions, RemoteCallbacks}; use git2::{
build::{CheckoutBuilder, RepoBuilder},
FetchOptions, RemoteCallbacks,
};
use crate::{ use crate::{
config::{CuddleConfig, CuddleFetchPolicy}, config::{CuddleConfig, CuddleFetchPolicy},
@ -128,8 +132,10 @@ fn pull_parent_cuddle_into_local(
let mut fo = FetchOptions::new(); let mut fo = FetchOptions::new();
fo.remote_callbacks(rc); fo.remote_callbacks(rc);
let co = CheckoutBuilder::new();
RepoBuilder::new() RepoBuilder::new()
.fetch_options(fo) .fetch_options(fo)
.with_checkout(co)
.clone(&parent_cuddle, &destination)?; .clone(&parent_cuddle, &destination)?;
log::debug!(parent_cuddle=log::as_display!(parent_cuddle); "pulled repository"); log::debug!(parent_cuddle=log::as_display!(parent_cuddle); "pulled repository");