From 35fdd16cf4fe15e63b0b49d7b454dc965ea7bbaa Mon Sep 17 00:00:00 2001 From: Postil Maintainer Date: Thu, 27 Aug 2026 03:20:07 +0000 Subject: [PATCH] Eliminate the pre-push hook test race --- src/hook.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/hook.rs b/src/hook.rs index 5304b79..1f1b2f9 100644 --- a/src/hook.rs +++ b/src/hook.rs @@ -174,7 +174,11 @@ mod tests { fake_bin.display(), std::env::var("PATH").unwrap_or_default() ); - let mut child = Command::new(hook) + // Executable permissions are asserted separately. Invoking the script + // through its interpreter avoids a transient ETXTBSY race on filesystems + // that delay releasing a newly written script for direct execution. + let mut child = Command::new("sh") + .arg(hook) .args(["origin", &remote.to_string_lossy()]) .current_dir(repo) .env("PATH", path) @@ -217,6 +221,7 @@ mod tests { install(dir.path(), false).unwrap(); let hook = dir.path().join(".git/hooks/pre-push"); let script = std::fs::read_to_string(&hook).unwrap(); + assert!(script.starts_with("#!/bin/sh\n")); assert!(script.contains("while read -r local_ref local_oid")); assert!(script.contains("git diff --find-renames \"$remote_oid\" \"$local_oid\"")); assert!(script.contains("postil review --bounded --diff-file \"$tmp\"")); @@ -280,7 +285,7 @@ mod tests { } #[test] - fn executable_hook_reviews_exact_refs_and_skips_non_branches() { + fn installed_hook_reviews_exact_refs_and_skips_non_branches() { let dir = tempfile::tempdir().unwrap(); let repo = dir.path().join("repo"); let remote = dir.path().join("remote.git");