git: Fix git hook hang with prek (#44212)
Fix git hook hang when using with `prek`. Can see [comments](https://github.com/zed-industries/zed/issues/44057#issuecomment-3606837089), this is easy test, should using release build, debug build sometimes not hang. The issue existing long time, see issue #37293 , and then in commit #42239 this issue had fixed. but in commit #43285 broken again. So I reference the implementation in #42239, then this code work. I MUST CLAIM, I really don't known what happend, and why this code work. But it worked. Release Notes: - N/A --------- Co-authored-by: Cole Miller <cole@zed.dev>
This commit is contained in:
co-authored by
Cole Miller
parent
25d74480aa
commit
7ed5d42696
@@ -2318,6 +2318,7 @@ impl GitRepository for RealGitRepository {
|
||||
let executor = self.executor.clone();
|
||||
let help_output = self.any_git_binary_help_output();
|
||||
|
||||
// Note: Do not spawn these commands on the background thread, as this causes some git hooks to hang.
|
||||
async move {
|
||||
let working_directory = working_directory?;
|
||||
if !help_output
|
||||
@@ -2327,14 +2328,10 @@ impl GitRepository for RealGitRepository {
|
||||
{
|
||||
let hook_abs_path = repository.lock().path().join("hooks").join(hook.as_str());
|
||||
if hook_abs_path.is_file() {
|
||||
let output = self
|
||||
.executor
|
||||
.spawn(
|
||||
new_smol_command(&hook_abs_path)
|
||||
.envs(env.iter())
|
||||
.current_dir(&working_directory)
|
||||
.output(),
|
||||
)
|
||||
let output = new_smol_command(&hook_abs_path)
|
||||
.envs(env.iter())
|
||||
.current_dir(&working_directory)
|
||||
.output()
|
||||
.await?;
|
||||
|
||||
if !output.status.success() {
|
||||
|
||||
Reference in New Issue
Block a user