mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-05 02:29:32 +00:00
Merge pull request #2486 from eureka-cpu/eureka-cpu/2485
fix `init --title` option failure when git user is not configured
This commit is contained in:
commit
d1078434af
2 changed files with 24 additions and 1 deletions
|
@ -74,9 +74,9 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
|
|||
if let Some(author) = get_author_name() {
|
||||
debug!("Obtained user name from gitconfig: {:?}", author);
|
||||
config.book.authors.push(author);
|
||||
builder.with_config(config);
|
||||
}
|
||||
|
||||
builder.with_config(config);
|
||||
builder.build()?;
|
||||
println!("\nAll done, no errors...");
|
||||
|
||||
|
|
|
@ -22,3 +22,26 @@ fn base_mdbook_init_can_skip_confirmation_prompts() {
|
|||
|
||||
assert!(!temp.path().join(".gitignore").exists());
|
||||
}
|
||||
|
||||
/// Run `mdbook init` with `--title` without git config.
|
||||
///
|
||||
/// Regression test for https://github.com/rust-lang/mdBook/issues/2485
|
||||
#[test]
|
||||
fn no_git_config_with_title() {
|
||||
let temp = DummyBook::new().build().unwrap();
|
||||
|
||||
// doesn't exist before
|
||||
assert!(!temp.path().join("book").exists());
|
||||
|
||||
let mut cmd = mdbook_cmd();
|
||||
cmd.args(["init", "--title", "Example title"])
|
||||
.current_dir(temp.path())
|
||||
.env("GIT_CONFIG_GLOBAL", "")
|
||||
.env("GIT_CONFIG_NOSYSTEM", "1");
|
||||
cmd.assert()
|
||||
.success()
|
||||
.stdout(predicates::str::contains("\nAll done, no errors...\n"));
|
||||
|
||||
let config = Config::from_disk(temp.path().join("book.toml")).unwrap();
|
||||
assert_eq!(config.book.title.as_deref(), Some("Example title"));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue