Skip to content

Commit 2497649

Browse files
authored
Disable git terminal prompts (#1193)
1 parent b5be7c6 commit 2497649

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

crates/prek-consts/src/env_vars.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ impl EnvVars {
99
pub const HOME: &'static str = "HOME";
1010
pub const CI: &'static str = "CI";
1111

12+
// Git related
13+
pub const GIT_TERMINAL_PROMPT: &'static str = "GIT_TERMINAL_PROMPT";
14+
1215
pub const SKIP: &'static str = "SKIP";
1316

1417
// PREK specific environment variables, public for users

src/git.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::sync::LazyLock;
77

88
use anyhow::Result;
99
use path_clean::PathClean;
10+
use prek_consts::env_vars::EnvVars;
1011
use rustc_hash::FxHashSet;
1112
use tokio::io::{AsyncReadExt, AsyncWriteExt};
1213
use tracing::{debug, instrument, warn};
@@ -367,6 +368,9 @@ async fn shallow_clone(rev: &str, path: &Path) -> Result<(), Error> {
367368
.arg("origin")
368369
.arg(rev)
369370
.arg("--depth=1")
371+
// Disable interactive prompts in the terminal, as they'll be erased by the progress bar
372+
// animation and the process will "hang".
373+
.env(EnvVars::GIT_TERMINAL_PROMPT, "0")
370374
.remove_git_env()
371375
.check(true)
372376
.output()
@@ -390,6 +394,7 @@ async fn shallow_clone(rev: &str, path: &Path) -> Result<(), Error> {
390394
.arg("--init")
391395
.arg("--recursive")
392396
.arg("--depth=1")
397+
.env(EnvVars::GIT_TERMINAL_PROMPT, "0")
393398
.remove_git_env()
394399
.check(true)
395400
.output()
@@ -404,6 +409,7 @@ async fn full_clone(rev: &str, path: &Path) -> Result<(), Error> {
404409
.arg("fetch")
405410
.arg("origin")
406411
.arg("--tags")
412+
.env(EnvVars::GIT_TERMINAL_PROMPT, "0")
407413
.remove_git_env()
408414
.check(true)
409415
.output()
@@ -424,6 +430,7 @@ async fn full_clone(rev: &str, path: &Path) -> Result<(), Error> {
424430
.arg("update")
425431
.arg("--init")
426432
.arg("--recursive")
433+
.env(EnvVars::GIT_TERMINAL_PROMPT, "0")
427434
.remove_git_env()
428435
.check(true)
429436
.output()

0 commit comments

Comments
 (0)