mirror of
https://github.com/instructkr/claude-code.git
synced 2026-06-04 11:36:44 +00:00
fix: keep hooks clean and close bash stdin
This commit is contained in:
2
.github/hooks/pre-push
vendored
2
.github/hooks/pre-push
vendored
@@ -13,7 +13,7 @@ cd "$repo_root"
|
|||||||
|
|
||||||
if [[ -x scripts/roadmap-check-ids.sh ]]; then
|
if [[ -x scripts/roadmap-check-ids.sh ]]; then
|
||||||
echo "pre-push: scripts/roadmap-check-ids.sh" >&2
|
echo "pre-push: scripts/roadmap-check-ids.sh" >&2
|
||||||
scripts/roadmap-check-ids.sh
|
scripts/roadmap-check-ids.sh >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${SKIP_CLAW_PRE_PUSH_BUILD:-}" == "1" ]]; then
|
if [[ "${SKIP_CLAW_PRE_PUSH_BUILD:-}" == "1" ]]; then
|
||||||
|
|||||||
@@ -330,20 +330,24 @@ fn prepare_tokio_command(
|
|||||||
prepare_sandbox_dirs(cwd);
|
prepare_sandbox_dirs(cwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(launcher) = build_linux_sandbox_command(command, cwd, sandbox_status) {
|
let mut prepared =
|
||||||
let mut prepared = TokioCommand::new(launcher.program);
|
if let Some(launcher) = build_linux_sandbox_command(command, cwd, sandbox_status) {
|
||||||
prepared.args(launcher.args);
|
let mut cmd = TokioCommand::new(launcher.program);
|
||||||
prepared.current_dir(cwd);
|
cmd.args(launcher.args);
|
||||||
prepared.envs(launcher.env);
|
cmd.envs(launcher.env);
|
||||||
return prepared;
|
cmd
|
||||||
}
|
} else {
|
||||||
|
let mut cmd = TokioCommand::new("sh");
|
||||||
|
cmd.arg("-lc").arg(command);
|
||||||
|
if sandbox_status.filesystem_active {
|
||||||
|
cmd.env("HOME", cwd.join(".sandbox-home"));
|
||||||
|
cmd.env("TMPDIR", cwd.join(".sandbox-tmp"));
|
||||||
|
}
|
||||||
|
cmd
|
||||||
|
};
|
||||||
|
|
||||||
let mut prepared = TokioCommand::new("sh");
|
prepared.current_dir(cwd);
|
||||||
prepared.arg("-lc").arg(command).current_dir(cwd);
|
prepared.stdin(Stdio::null());
|
||||||
if sandbox_status.filesystem_active {
|
|
||||||
prepared.env("HOME", cwd.join(".sandbox-home"));
|
|
||||||
prepared.env("TMPDIR", cwd.join(".sandbox-tmp"));
|
|
||||||
}
|
|
||||||
prepared
|
prepared
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,6 +423,27 @@ mod tests {
|
|||||||
assert_eq!(structured[0]["event"], "test.hung");
|
assert_eq!(structured[0]["event"], "test.hung");
|
||||||
assert_eq!(structured[0]["data"]["provenance"], "bash.timeout");
|
assert_eq!(structured[0]["data"]["provenance"], "bash.timeout");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn prevents_stdin_hangs_by_redirecting_to_null() {
|
||||||
|
let output = execute_bash(BashCommandInput {
|
||||||
|
command: String::from("cat"),
|
||||||
|
timeout: Some(2_000),
|
||||||
|
description: None,
|
||||||
|
run_in_background: Some(false),
|
||||||
|
dangerously_disable_sandbox: Some(true),
|
||||||
|
namespace_restrictions: None,
|
||||||
|
isolate_network: None,
|
||||||
|
filesystem_mode: None,
|
||||||
|
allowed_mounts: None,
|
||||||
|
})
|
||||||
|
.expect("bash command should execute cleanly");
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
!output.interrupted,
|
||||||
|
"Command hung and was cut off by the timeout!"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Maximum output bytes before truncation (16 KiB, matching upstream).
|
/// Maximum output bytes before truncation (16 KiB, matching upstream).
|
||||||
|
|||||||
Reference in New Issue
Block a user