From ee32b6e25cf042892867ae21bb72095cfda8be9c Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 30 May 2021 16:44:57 +0200 Subject: git::mirror(): Write empty description if `description` is `None` This gets rid of the default description string: Unnamed repository; edit this file 'description' to name the repository. --- src/git.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/git.rs') diff --git a/src/git.rs b/src/git.rs index 7ad919f..479a3c5 100644 --- a/src/git.rs +++ b/src/git.rs @@ -22,14 +22,17 @@ pub fn mirror>( path: P, description: Option<&str>, ) -> Result<(), Error> { - let mut repo_init_options = git2::RepositoryInitOptions::new(); - repo_init_options.bare(true); - - if let Some(d) = description { - repo_init_options.description(d); - } - - let repo = git2::Repository::init_opts(path, &repo_init_options)?; + let description_str = match description { + Some(d) => d, + None => "", + }; + + let repo = git2::Repository::init_opts( + path, + &git2::RepositoryInitOptions::new() + .bare(true) + .description(description_str), + )?; let remote_name = "origin"; -- cgit v1.2.3