Skip to content

Commit 83df6dd

Browse files
committed
test that proved hook has access to PATH (gitui-org#1967)
1 parent 91242e5 commit 83df6dd

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

asyncgit/src/sync/hooks.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,30 @@ exit 1
340340
assert!(res != HookResult::Ok);
341341
}
342342

343+
#[test]
344+
fn test_env_containing_path() {
345+
let (_td, repo) = repo_init().unwrap();
346+
let root = repo.path().parent().unwrap();
347+
let repo_path: &RepoPath =
348+
&root.as_os_str().to_str().unwrap().into();
349+
350+
let hook = b"#!/bin/sh
351+
export
352+
exit 1
353+
";
354+
355+
create_hook(repo_path, HOOK_PRE_COMMIT, hook);
356+
let res = hooks_pre_commit(repo_path).unwrap();
357+
358+
let HookResult::NotOk(out) = res else {
359+
unreachable!()
360+
};
361+
362+
assert!(out
363+
.lines()
364+
.any(|line| line.starts_with("export PATH")));
365+
}
366+
343367
#[test]
344368
fn test_pre_commit_fail_hookspath() {
345369
let (_td, repo) = repo_init().unwrap();

0 commit comments

Comments
 (0)