updated addremoterepo!
This commit is contained in:
parent
a514ff72d2
commit
bfdd939fc1
17
src/git.rs
17
src/git.rs
@ -58,7 +58,7 @@ pub async fn handle_git(cmd: &GitCommand) {
|
||||
print!("{ls}");
|
||||
}
|
||||
|
||||
GitCommand::Add { name } => { add_remote_to_repo(name.to_string()); }
|
||||
GitCommand::Add { name } => { add_remote_to_repo(name, &session).await; }
|
||||
|
||||
GitCommand::Clone { name } => { clone_repo(name, &session).await; }
|
||||
}
|
||||
@ -106,19 +106,28 @@ async fn choose_repo_from_list(session: &Session) -> String {
|
||||
}
|
||||
|
||||
|
||||
fn add_remote_to_repo(name: String) {
|
||||
async fn add_remote_to_repo(name: &Option<String>, session: &Session) {
|
||||
let unwrapped_name: String;
|
||||
|
||||
// check if name is null and present list if so
|
||||
if name.is_none() {
|
||||
unwrapped_name = choose_repo_from_list(session).await;
|
||||
} else {
|
||||
unwrapped_name = name.clone().unwrap();
|
||||
}
|
||||
|
||||
let cmd = Command::new("git")
|
||||
.arg("remote")
|
||||
.arg("add")
|
||||
.arg("origin")
|
||||
.arg("git@breadpi:/home/git/store/".to_owned() + &name + ".git")
|
||||
.arg("git@breadpi:/home/git/store/".to_owned() + &unwrapped_name + ".git")
|
||||
.output().expect("Could not add remote");
|
||||
eprintln!(
|
||||
"{}",
|
||||
String::from_utf8(cmd.stdout).expect("Failed to add git remote.")
|
||||
);
|
||||
|
||||
println!("Added remote origin git@breadpi:/home/git/store/{name}.git");
|
||||
println!("Added remote origin git@breadpi:/home/git/store/{unwrapped_name}.git");
|
||||
}
|
||||
|
||||
async fn init_repo(name: &Option<String>, session: &Session) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user