From 6802b5ed46bba4ce6818a909f1e3fce0174e9ba0 Mon Sep 17 00:00:00 2001 From: Jacob Casper Date: Sat, 12 Jun 2021 17:51:38 -0500 Subject: [PATCH] Fix repos being created with target machine as remote name "public" is hard coded and not configurable in the default mirroring script, so we should hard code it as well instead of using the name of the public machine. --- src/main.rs | 54 +++++++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/src/main.rs b/src/main.rs index bc758e4..6a59113 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,36 +18,32 @@ fn check_ip() -> Result<(), Box> { } fn main() -> Result<(), Box> { - match check_ip() { - Ok(()) => { - let mut repo_name = String::new(); - io::stdin().read_line(&mut repo_name)?; - // remove trailing newline - repo_name.pop(); + check_ip()?; + let mut repo_name = String::new(); + io::stdin().read_line(&mut repo_name)?; + // remove trailing newline + repo_name.pop(); - let mut opts = git2::RepositoryInitOptions::new(); - git2::RepositoryInitOptions::bare(&mut opts, true) - .mode(git2::RepositoryInitMode::SHARED_GROUP) - .no_reinit(true) - .template_path(path::Path::new("./templates")); + let mut opts = git2::RepositoryInitOptions::new(); + git2::RepositoryInitOptions::bare(&mut opts, true) + .mode(git2::RepositoryInitMode::SHARED_GROUP) + .no_reinit(true) + .template_path(path::Path::new("./templates")); - let repo = git2::Repository::init_opts(format!("{}.git", repo_name), &opts)?; + let repo = git2::Repository::init_opts(format!("{}.git", repo_name), &opts)?; - let public_user = env::var("USER")?; - let public_name = env::var("PUBLIC")?; - let public_path = env::var("PATH")?; - repo.remote( - &public_name, - &format!( - "{user}@{public}:{path}/{repo}.git", - user = public_user, - public = public_name, - path = public_path, - repo = repo_name - ), - )?; - Ok(()) - } - Err(e) => Err(e), - } + let public_user = env::var("USER")?; + let public_name = env::var("PUBLIC")?; + let public_path = env::var("PATH")?; + repo.remote( + "public", + &format!( + "{user}@{public}:{path}/{repo}.git", + user = public_user, + public = public_name, + path = public_path, + repo = repo_name + ), + )?; + Ok(()) } -- 2.20.1