diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2025-01-26 22:21:29 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2025-01-26 22:21:29 +0100 |
| commit | 790e1af298aa7c9f39fb7cfe15615307ed87d597 (patch) | |
| tree | ee911ccc4b3681462175f7a49224e44c9acd8070 /server/src/git.rs | |
| parent | 5807838b553bb8e3add15025925d5c60afd56cfc (diff) | |
Fix tests after adding git repos
Use testdir to create directories to put test git in.
Use custom test method to find githook binary.
Stop using remote so that git repo doesn't try to fetch.
Diffstat (limited to 'server/src/git.rs')
| -rw-r--r-- | server/src/git.rs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/server/src/git.rs b/server/src/git.rs index 652eb29..9fb0593 100644 --- a/server/src/git.rs +++ b/server/src/git.rs @@ -117,10 +117,7 @@ impl RepoData { } async fn sync_hooks(&mut self, repo: &Repository) -> Result<(), Error> { - let server_exe = - std::env::current_exe().map_err(|e| io_err("unable to get current exe", e))?; - - let hook = server_exe.parent().unwrap().join("eyeballs-githook"); + let hook = get_githook_bin()?; let hooks = if repo.is_bare() { repo.path().join("hooks") @@ -449,3 +446,20 @@ impl Repository { .await } } + +#[cfg(not(test))] +fn get_githook_bin() -> Result<PathBuf, Error> { + let server_exe = std::env::current_exe().map_err(|e| io_err("unable to get current exe", e))?; + Ok(server_exe.parent().unwrap().join("eyeballs-githook")) +} + +#[cfg(test)] +fn get_githook_bin() -> Result<PathBuf, Error> { + let test_exe = std::env::current_exe().map_err(|e| io_err("unable to get current exe", e))?; + Ok(test_exe + .parent() + .unwrap() + .parent() + .unwrap() + .join("eyeballs-githook")) +} |
