Adds support for GCLONE_FORCE_SSH env
This commit is contained in:
parent
9fefbb8c3a
commit
d5f8834bcb
12
src/git.rs
12
src/git.rs
|
@ -109,6 +109,12 @@ pub fn clone<P: AsRef<Path>>(url: &str, place: P) -> Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Rewrites an url to a SSH url.
|
||||||
|
pub fn rewrite_url(url: &str) -> Result<String> {
|
||||||
|
let (server, owner, repo) = parse_url(url)?;
|
||||||
|
Ok(parse_to_url(&server, &owner, &repo))
|
||||||
|
}
|
||||||
|
|
||||||
/// Clones a git repository in the right place.
|
/// Clones a git repository in the right place.
|
||||||
fn clone_dirty<P: AsRef<Path>>(url: &str, place: P) -> Result<()> {
|
fn clone_dirty<P: AsRef<Path>>(url: &str, place: P) -> Result<()> {
|
||||||
let place = place.as_ref();
|
let place = place.as_ref();
|
||||||
|
@ -118,6 +124,12 @@ fn clone_dirty<P: AsRef<Path>>(url: &str, place: P) -> Result<()> {
|
||||||
create_dir_all(parent)?;
|
create_dir_all(parent)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let url = if env::var("GCLONE_FORCE_SSH") == Ok("true".to_owned()) {
|
||||||
|
rewrite_url(url)?
|
||||||
|
} else {
|
||||||
|
url.to_owned()
|
||||||
|
};
|
||||||
|
|
||||||
let command = Command::new("git")
|
let command = Command::new("git")
|
||||||
.args(&[
|
.args(&[
|
||||||
"clone",
|
"clone",
|
||||||
|
|
Loading…
Reference in New Issue