Skip to content

Commit a04a790

Browse files
committed
improve git test isolation
1 parent 424be21 commit a04a790

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

helix-vcs/src/git/test.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ fn exec_git_cmd(args: &str, git_dir: &Path) {
99
.arg("-C")
1010
.arg(git_dir) // execute the git command in this directory
1111
.args(args.split_whitespace())
12+
.env_remove("GIT_DIR")
13+
.env_remove("GIT_ASKPASS")
14+
.env_remove("SSH_ASKPASS")
15+
.env("GIT_TERMINAL_PROMPT", "false")
16+
.env("GIT_AUTHOR_DATE", "2000-01-01 00:00:00 +0000")
17+
.env("GIT_AUTHOR_EMAIL", "[email protected]")
18+
.env("GIT_AUTHOR_NAME", "author")
19+
.env("GIT_COMMITTER_DATE", "2000-01-02 00:00:00 +0000")
20+
.env("GIT_COMMITTER_EMAIL", "[email protected]")
21+
.env("GIT_COMMITTER_NAME", "committer")
22+
.env("GIT_CONFIG_COUNT", "2")
23+
.env("GIT_CONFIG_KEY_0", "commit.gpgsign")
24+
.env("GIT_CONFIG_VALUE_0", "false")
25+
.env("GIT_CONFIG_KEY_1", "init.defaultBranch")
26+
.env("GIT_CONFIG_VALUE_1", "main")
1227
.output()
1328
.unwrap_or_else(|_| panic!("`git {args}` failed"));
1429
if !res.status.success() {
@@ -22,7 +37,7 @@ fn create_commit(repo: &Path, add_modified: bool) {
2237
if add_modified {
2338
exec_git_cmd("add -A", repo);
2439
}
25-
exec_git_cmd("commit -m message --no-gpg-sign", repo);
40+
exec_git_cmd("commit -m message", repo);
2641
}
2742

2843
fn empty_git_repo() -> TempDir {

0 commit comments

Comments
 (0)