summaryrefslogtreecommitdiff
path: root/src/git.rs
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-06-24 21:52:37 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-06-24 21:52:37 +0200
commitda8802d1fb0c5707877777ff4187238195eef16b (patch)
tree60b6d9ca408d252c2f6e96b1c90a3993c3f0dc39 /src/git.rs
parent20ff259800f3a5568c53fca3992c4e062282b82a (diff)
Added a command to delete a repo
Diffstat (limited to 'src/git.rs')
-rw-r--r--src/git.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/git.rs b/src/git.rs
index 07ec775..c07615d 100644
--- a/src/git.rs
+++ b/src/git.rs
@@ -194,6 +194,19 @@ pub fn set_branch(directory: &Path, branch: &str) -> Result<(), ShackleError> {
}
}
+pub fn delete(directory: &Path) -> Result<(), ShackleError> {
+ if !is_valid_git_repo_path(directory)? {
+ return Err(ShackleError::InvalidDirectory);
+ }
+
+ if Repository::open_bare(directory).is_ok() {
+ fs::remove_dir_all(directory)?;
+ Ok(())
+ } else {
+ Err(ShackleError::InvalidDirectory)
+ }
+}
+
pub fn upload_pack(upload_pack_args: &GitUploadPackArgs) -> Result<(), ShackleError> {
if !is_valid_git_repo_path(&upload_pack_args.directory)? {
return Err(ShackleError::InvalidDirectory);