summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-04-09 21:59:16 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-04-09 21:59:16 +0200
commitea5682e7291b9839778a6c3e75fcbc42515ef6ea (patch)
tree2cc4ed49ddaac97b8e1dab9b8cfecedbcc443f8b /src
parentff5e3b4dd718e622d81e02c50786c2ec3d5437ae (diff)
Implement set_description for an existing repo
Diffstat (limited to 'src')
-rw-r--r--src/git.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/git.rs b/src/git.rs
index 0ef9a42..979e7b9 100644
--- a/src/git.rs
+++ b/src/git.rs
@@ -170,8 +170,17 @@ pub fn list() -> Result<Vec<RepoMetadata>, ShackleError> {
Ok(results)
}
-pub fn set_description(_directory: &PathBuf, _description: &str) -> Result<(), ShackleError> {
- todo!()
+pub fn set_description(directory: &PathBuf, description: &str) -> Result<(), ShackleError> {
+ if !is_valid_git_repo_path(&directory)? {
+ return Err(ShackleError::InvalidDirectory);
+ }
+
+ let description_path = directory.join("description");
+ if description_path.is_file() {
+ fs::write(description_path, description).map_err(|e| e.into())
+ } else {
+ Err(ShackleError::InvalidDirectory)
+ }
}
pub fn upload_pack(upload_pack_args: &GitUploadPackArgs) -> Result<(), ShackleError> {