Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed Nov 23, 2024
1 parent 43050ec commit f8d0e85
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
22 changes: 20 additions & 2 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("[email protected]")
.current_dir(&self.temp_dir)
.assert()
.success();
}

/// Run `git add`.
pub fn git_add(&self, path: impl AsRef<OsStr>) {
Command::new("git")
.arg("add")
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion tests/hook_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn hook_impl() {
"});

context.git_add(".");

context.configure_git_author();
let mut commit = Command::new("git");
commit
.arg("commit")
Expand Down
1 change: 1 addition & 0 deletions tests/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit f8d0e85

Please sign in to comment.