diff options
author | Justin Wernick <justin@worthe-it.co.za> | 2023-04-09 21:59:16 +0200 |
---|---|---|
committer | Justin Wernick <justin@worthe-it.co.za> | 2023-04-09 21:59:16 +0200 |
commit | ea5682e7291b9839778a6c3e75fcbc42515ef6ea (patch) | |
tree | 2cc4ed49ddaac97b8e1dab9b8cfecedbcc443f8b /src | |
parent | ff5e3b4dd718e622d81e02c50786c2ec3d5437ae (diff) |
Implement set_description for an existing repo
Diffstat (limited to 'src')
-rw-r--r-- | src/git.rs | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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> { |