Auto-detect CI/TUI mode for non-interactive environments and improve patch application robustness
- apply-patches.sh: add signature-marker checks for build-system patches to handle cases where reverse-check fails but patch is already applied - test-baremetal.sh: auto-disable TUI when stdout is not a terminal; pass CI=1 to make - test-live-iso-qemu.sh: pass CI=1 via env to prevent repo cook panic - scripts/run.sh: auto-disable TUI when stdout is not a terminal; pass CI=1 to qemu launch - repo.rs: improve TUI initialization error messages (raw mode + alternate screen) and rustfmt cleanups - config.rs: auto-detect TTY presence for TUI enablement; use is_terminal() instead of relying solely on CI env var
This commit is contained in:
+9
-7
@@ -1032,7 +1032,11 @@ impl TuiApp {
|
||||
thread::spawn(move || {
|
||||
while let Ok(msg) = log_writer_rx.recv() {
|
||||
match msg {
|
||||
LogWriterMessage::Write { _name, path, content } => {
|
||||
LogWriterMessage::Write {
|
||||
_name,
|
||||
path,
|
||||
content,
|
||||
} => {
|
||||
if content.trim_end().is_empty() {
|
||||
continue;
|
||||
}
|
||||
@@ -1157,10 +1161,8 @@ impl TuiApp {
|
||||
}
|
||||
StatusUpdate::FlushLog(name, path) => {
|
||||
let (logs, line) = self.get_recipe_log(&name);
|
||||
let content = strip_ansi_escapes::strip_str(join_logs(
|
||||
logs.unwrap_or(&Vec::new()),
|
||||
line,
|
||||
));
|
||||
let content =
|
||||
strip_ansi_escapes::strip_str(join_logs(logs.unwrap_or(&Vec::new()), line));
|
||||
let _ = self.log_writer_tx.send(LogWriterMessage::Write {
|
||||
_name: name,
|
||||
path,
|
||||
@@ -1328,9 +1330,9 @@ fn run_tui_cook(config: CliConfig, recipes: Vec<CookRecipe>) -> Result<TuiApp, c
|
||||
let mstdin = stdin();
|
||||
let mstdout = stdout()
|
||||
.into_raw_mode()
|
||||
.unwrap()
|
||||
.map_err(|e| Error::from_io_error(e, "Entering raw terminal mode (try CI=1)"))?
|
||||
.into_alternate_screen()
|
||||
.unwrap();
|
||||
.map_err(|e| Error::from_io_error(e, "Entering alternate terminal screen"))?;
|
||||
|
||||
// ----- Input Thread -----
|
||||
let (input_tx, input_rx) = mpsc::channel::<Event>();
|
||||
|
||||
+10
-2
@@ -1,4 +1,10 @@
|
||||
use std::{collections::HashMap, env, fs, str::FromStr, sync::OnceLock};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
env, fs,
|
||||
io::{IsTerminal, stdin},
|
||||
str::FromStr,
|
||||
sync::OnceLock,
|
||||
};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -86,7 +92,9 @@ pub fn init_config() {
|
||||
};
|
||||
|
||||
if config.cook_opt.tui.is_none() {
|
||||
config.cook_opt.tui = Some(!env::var("CI").is_ok_and(|s| !s.is_empty()));
|
||||
let ci_set = env::var("CI").is_ok_and(|s| !s.is_empty());
|
||||
let tty = stdin().is_terminal();
|
||||
config.cook_opt.tui = Some(!ci_set && tty);
|
||||
}
|
||||
if config.cook_opt.jobs.is_none() {
|
||||
config.cook_opt.jobs = Some(extract_env(
|
||||
|
||||
Reference in New Issue
Block a user