fix init --title option failure when git user is not configured

This commit is contained in:
eureka-cpu 2024-11-17 03:02:01 -08:00 committed by Eric Huss
parent 0c580c32c4
commit 8f024dabc3
2 changed files with 2 additions and 2 deletions

View file

@ -74,9 +74,9 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
if let Some(author) = get_author_name() { if let Some(author) = get_author_name() {
debug!("Obtained user name from gitconfig: {:?}", author); debug!("Obtained user name from gitconfig: {:?}", author);
config.book.authors.push(author); config.book.authors.push(author);
builder.with_config(config);
} }
builder.with_config(config);
builder.build()?; builder.build()?;
println!("\nAll done, no errors..."); println!("\nAll done, no errors...");

View file

@ -43,5 +43,5 @@ fn no_git_config_with_title() {
.stdout(predicates::str::contains("\nAll done, no errors...\n")); .stdout(predicates::str::contains("\nAll done, no errors...\n"));
let config = Config::from_disk(temp.path().join("book.toml")).unwrap(); let config = Config::from_disk(temp.path().join("book.toml")).unwrap();
assert_eq!(config.book.title, None); assert_eq!(config.book.title.as_deref(), Some("Example title"));
} }