Added clone command, fixed copy-paste errors
This commit is contained in:
parent
f10707e224
commit
f158a1ab77
32
src/git.rs
32
src/git.rs
@ -26,6 +26,13 @@ pub enum GitCommand {
|
||||
#[arg()]
|
||||
/// Name of the repo
|
||||
name: String
|
||||
},
|
||||
|
||||
/// Clone a repo from the remote
|
||||
Clone {
|
||||
#[arg()]
|
||||
/// Name of the repo
|
||||
name: String
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,11 +79,13 @@ pub async fn handle_git(cmd: &GitCommand) {
|
||||
|
||||
eprintln!(
|
||||
"{}",
|
||||
String::from_utf8(ls.stdout).expect("Failed to rm repo.")
|
||||
String::from_utf8(ls.stdout).expect("Failed to list repos.")
|
||||
);
|
||||
}
|
||||
|
||||
GitCommand::Add { name } => { add_remote_to_repo(name.to_string()); }
|
||||
|
||||
GitCommand::Clone { name } => { clone_repo(name.to_string()); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,12 +95,27 @@ fn add_remote_to_repo(name: String) {
|
||||
.arg("remote")
|
||||
.arg("add")
|
||||
.arg("origin")
|
||||
.arg("git@breadpi.local:/home/git/store/".to_owned() + &name + ".git")
|
||||
.arg("git@breadpi:/home/git/store/".to_owned() + &name + ".git")
|
||||
.output().expect("Could not add remote");
|
||||
eprintln!(
|
||||
"{}",
|
||||
String::from_utf8(cmd.stdout).expect("Failed to rm git repo.")
|
||||
String::from_utf8(cmd.stdout).expect("Failed to add git remote.")
|
||||
);
|
||||
|
||||
println!("Added remote origin git@breadpi.local:/home/git/store/{name}.git");
|
||||
println!("Added remote origin git@breadpi:/home/git/store/{name}.git");
|
||||
}
|
||||
|
||||
|
||||
fn clone_repo(name: String) {
|
||||
let cmd = Command::new("git")
|
||||
.arg("clone")
|
||||
.arg("git@breadpi:/home/git/store/".to_owned() + &name + ".git")
|
||||
.output().expect("Could not clone repo");
|
||||
|
||||
eprintln!(
|
||||
"{}",
|
||||
String::from_utf8(cmd.stdout).expect("Failed to clone repo.")
|
||||
);
|
||||
|
||||
println!("Clone repo git@breadpi:/home/git/store/{name}.git to local folder.");
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user