diff options
author | extrawurst <mail@rusticorn.com> | 2023-12-02 12:59:42 +0100 |
---|---|---|
committer | extrawurst <776816+extrawurst@users.noreply.github.com> | 2023-12-02 13:21:33 +0100 |
commit | 83df6ddbc8ee58b08fa616fc04c4c8559be6ebec (patch) | |
tree | 7c251dc457c9af6a5ac908cad31b4fd7a113e4db | |
parent | 91242e574ac0ebd7a8d276329304309f4e83e282 (diff) |
test that proved hook has access to PATH (#1967)
-rw-r--r-- | asyncgit/src/sync/hooks.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/asyncgit/src/sync/hooks.rs b/asyncgit/src/sync/hooks.rs index f4588715..00f7a2cd 100644 --- a/asyncgit/src/sync/hooks.rs +++ b/asyncgit/src/sync/hooks.rs @@ -341,6 +341,30 @@ exit 1 } #[test] + fn test_env_containing_path() { + let (_td, repo) = repo_init().unwrap(); + let root = repo.path().parent().unwrap(); + let repo_path: &RepoPath = + &root.as_os_str().to_str().unwrap().into(); + + let hook = b"#!/bin/sh +export +exit 1 + "; + + create_hook(repo_path, HOOK_PRE_COMMIT, hook); + let res = hooks_pre_commit(repo_path).unwrap(); + + let HookResult::NotOk(out) = res else { + unreachable!() + }; + + assert!(out + .lines() + .any(|line| line.starts_with("export PATH"))); + } + + #[test] fn test_pre_commit_fail_hookspath() { let (_td, repo) = repo_init().unwrap(); let root = repo.path().parent().unwrap(); |