From 755e28d044aaff9a8aa0fa4700105564726ec33d Mon Sep 17 00:00:00 2001 From: Justin Wernick Date: Fri, 14 Jul 2023 13:13:11 +0200 Subject: Add a housekeeping task, which does git gc --- src/git.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/git.rs') diff --git a/src/git.rs b/src/git.rs index d92b5a0..76ff326 100644 --- a/src/git.rs +++ b/src/git.rs @@ -234,6 +234,20 @@ pub fn set_branch(directory: &Path, branch: &str) -> Result<(), ShackleError> { } } +pub fn housekeeping(directory: &Path) -> Result<(), ShackleError> { + if !is_valid_git_repo_path(directory)? { + return Err(ShackleError::InvalidDirectory); + } + + Command::new("git") + .arg("gc") + .current_dir(directory) + .spawn()? + .wait()?; + + Ok(()) +} + pub fn delete(directory: &Path) -> Result<(), ShackleError> { if !is_valid_git_repo_path(directory)? { return Err(ShackleError::InvalidDirectory); -- cgit v1.2.3