diff options
| author | Bond_009 <bond.009@outlook.com> | 2020-11-16 23:05:09 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2020-11-16 23:05:09 +0100 |
| commit | db2ed2b36776f1093d67d212bc3295f148039c0d (patch) | |
| tree | 4e23ea8ad65aed796296ebc52d79a48a03ec55ba /src/utils.rs | |
| parent | 70938201e78791c8c8dd608419904549449909c4 (diff) | |
Add ability to set description
Diffstat (limited to 'src/utils.rs')
| -rw-r--r-- | src/utils.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/utils.rs b/src/utils.rs index 6e737aa..f7c31be 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,3 +1,9 @@ +use std::{ + fs::File, + io::{Result, Write}, + path::Path +}; + pub fn get_repo_name(url: &str) -> &str { let start = url.rfind('/').unwrap_or_default() + 1; if url.ends_with(".git") @@ -8,6 +14,13 @@ pub fn get_repo_name(url: &str) -> &str { &url[start..] } +pub fn set_description(path: &Path, description: &str) -> Result<()> { + let mut path_buf = path.to_path_buf(); + path_buf.push(".git/description"); + let mut file = File::create(&path_buf)?; + file.write_all(description.as_bytes()) +} + #[cfg(test)] mod tests { use super::*; |
