diff --git a/Cargo.lock b/Cargo.lock index 28a935b03..157118ae6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1362,7 +1362,6 @@ dependencies = [ "libc", "libgit2-sys", "log", - "openssl-probe", "openssl-sys", "url", ] @@ -1850,7 +1849,6 @@ checksum = "d0fa6563431ede25f5cc7f6d803c6afbc1c5d3ad3d4925d12c882bf2b526f5d1" dependencies = [ "cc", "libc", - "libssh2-sys", "libz-sys", "openssl-sys", "pkg-config", @@ -1866,20 +1864,6 @@ dependencies = [ "libc", ] -[[package]] -name = "libssh2-sys" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b094a36eb4b8b8c8a7b4b8ae43b2944502be3e59cd87687595cf6b0a71b3f4ca" -dependencies = [ - "cc", - "libc", - "libz-sys", - "openssl-sys", - "pkg-config", - "vcpkg", -] - [[package]] name = "libz-sys" version = "1.1.8" @@ -3000,8 +2984,8 @@ version = "0.0.0" dependencies = [ "assert_fs", "ci_info", - "git2", "reqwest", + "rover-client", "saucer", "semver", "serde", diff --git a/crates/sputnik/Cargo.toml b/crates/sputnik/Cargo.toml index 2f247be14..1d6d23b9f 100644 --- a/crates/sputnik/Cargo.toml +++ b/crates/sputnik/Cargo.toml @@ -8,8 +8,8 @@ publish = false [dependencies] ci_info = { version = "0.14", features = ["serde-1"] } -git2 = "0.14" reqwest = { version = "0.11", default-features = false, features = ["blocking", "socks"] } +rover-client = { path = "../rover-client" } saucer = { git = "https://github.com/EverlastingBugstopper/awc.git", branch = "main" } # saucer = { path = "../../../awc/saucer" } semver = { version = "1", features = ["serde"] } diff --git a/crates/sputnik/src/session.rs b/crates/sputnik/src/session.rs index 60205b0ed..5de1bc390 100644 --- a/crates/sputnik/src/session.rs +++ b/crates/sputnik/src/session.rs @@ -1,7 +1,7 @@ use ci_info::types::Vendor as CiVendor; -use git2::Repository; use reqwest::blocking::Client; use reqwest::Url; +use rover_client::shared::GitContext; use saucer::Utf8PathBuf; use semver::Version; use serde::Serialize; @@ -97,7 +97,7 @@ impl Session { let current_dir = Utf8PathBuf::try_from(env::current_dir()?)?; let session_id = Uuid::new_v4(); let cwd_hash = get_cwd_hash(¤t_dir); - let remote_url_hash = get_repo_hash(¤t_dir); + let remote_url_hash = get_repo_hash(); let continuous_integration = if ci_info::is_ci() { ci_info::get().vendor @@ -157,15 +157,8 @@ fn get_cwd_hash(current_dir: &Utf8PathBuf) -> String { } /// returns sha256 digest of the repository the tool was executed from. -fn get_repo_hash(current_dir: &Utf8PathBuf) -> Option { - let repo = Repository::discover(current_dir); - if let Ok(repo) = repo { - if let Ok(remote) = repo.find_remote("origin") { - if let Some(remote_url) = remote.url() { - return Some(format!("{:x}", Sha256::digest(remote_url.as_bytes()))); - } - } - } - - None +fn get_repo_hash() -> Option { + GitContext::default() + .remote_url + .map(|remote_url| format!("{:x}", Sha256::digest(remote_url.as_bytes()))) }