summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-03-20 17:06:10 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-03-20 17:06:10 +0200
commitae4b23d95dc8792231c1e8212978be8305ee1964 (patch)
treeee90aee13789a37097ed39252404aa8a4b7d1c1e /src/main.rs
parent2ab7df378d8cb40775ac0ecd2849fa9966386a2e (diff)
Refactor git functions into the git module
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs34
1 files changed, 3 insertions, 31 deletions
diff --git a/src/main.rs b/src/main.rs
index 56cd729..4b62aa1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,7 +4,7 @@ mod parser;
use clap::Parser;
use parser::*;
use rustyline::{error::ReadlineError, DefaultEditor};
-use std::{io, ops::ControlFlow, process::Command};
+use std::{io, ops::ControlFlow};
use thiserror::Error;
/// Shackle Shell - A replacement for git-shell with repo management commands built in.
@@ -44,38 +44,10 @@ fn run_command(user_input: String) -> Result<ControlFlow<(), ()>, ShackleError>
println!("Successfully created \"{}.git\"", repo_name);
}
Ok(ShackleCommand::GitUploadPack(upload_pack_args)) => {
- let mut command = Command::new("git-upload-pack");
-
- if upload_pack_args.strict {
- command.arg("strict");
- }
- if upload_pack_args.no_strict {
- command.arg("no-strict");
- }
- if let Some(timeout) = upload_pack_args.timeout {
- command.args(["timeout", &timeout.to_string()]);
- }
- if upload_pack_args.stateless_rpc {
- command.arg("stateless-rpc");
- }
- if upload_pack_args.advertise_refs {
- command.arg("advertise-refs");
- }
-
- command.arg(&upload_pack_args.directory);
-
- command.spawn()?.wait()?;
+ git::upload_pack(&upload_pack_args)?;
}
Ok(ShackleCommand::GitReceivePack(receive_pack_args)) => {
- let mut command = Command::new("git-receive-pack");
-
- if receive_pack_args.http_backend_info_refs {
- command.arg("--http-backend-info-refs");
- }
-
- command.arg(&receive_pack_args.directory);
-
- command.spawn()?.wait()?;
+ git::receive_pack(&receive_pack_args)?;
}
}
Ok(ControlFlow::Continue(()))