diff --git a/tests/common/mod.rs b/tests/common/mod.rs index f9cf369..6cd9d5f 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -186,7 +186,25 @@ impl TestContext { .success(); } - /// Run `git add` in the temporary directory. + /// Configure git user and email. + pub fn configure_git_author(&self) { + Command::new("git") + .arg("config") + .arg("user.name") + .arg("Pre-Commit Test") + .current_dir(&self.temp_dir) + .assert() + .success(); + Command::new("git") + .arg("config") + .arg("user.email") + .arg("test@pre-commit-rs.dev") + .current_dir(&self.temp_dir) + .assert() + .success(); + } + + /// Run `git add`. pub fn git_add(&self, path: impl AsRef) { Command::new("git") .arg("add") @@ -196,7 +214,7 @@ impl TestContext { .success(); } - /// Run `git commit` in the temporary directory. + /// Run `git commit`. pub fn git_commit(&self, message: &str) { Command::new("git") .arg("commit") diff --git a/tests/hook_impl.rs b/tests/hook_impl.rs index f4a4596..77f468b 100644 --- a/tests/hook_impl.rs +++ b/tests/hook_impl.rs @@ -25,7 +25,7 @@ fn hook_impl() { "}); context.git_add("."); - + context.configure_git_author(); let mut commit = Command::new("git"); commit .arg("commit") diff --git a/tests/run.rs b/tests/run.rs index 38c2948..1f79a26 100644 --- a/tests/run.rs +++ b/tests/run.rs @@ -728,6 +728,7 @@ fn merge_conflicts() -> Result<()> { let cwd = context.workdir(); cwd.child("file.txt").write_str("Hello, world!")?; context.git_add("."); + context.configure_git_author(); context.git_commit("Initial commit"); Command::new("git")