From 9a6afd0362acee1ee9685f50e6c5286a19baf6d9 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Sat, 11 Nov 2023 21:29:32 +0300 Subject: [PATCH] write .last-warned-change-id only if environment is tty As the .last-warned-change-id is only used for change tracking, we don't need to generate/write it outside of the tty. Otherwise, rust-analyzer could create this file, and developers wouldn't be able to see the bootstrap change alerts, assuming that they have already seen them. Signed-off-by: onur-ozkan --- src/bootstrap/src/bin/main.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/src/bin/main.rs b/src/bootstrap/src/bin/main.rs index eb3fa0783a19..35010bea8187 100644 --- a/src/bootstrap/src/bin/main.rs +++ b/src/bootstrap/src/bin/main.rs @@ -9,7 +9,10 @@ use std::io::Write; #[cfg(all(any(unix, windows), not(target_os = "solaris")))] use std::process; -use std::{env, fs}; +use std::{ + env, fs, + io::{self, IsTerminal}, +}; #[cfg(all(any(unix, windows), not(target_os = "solaris")))] use bootstrap::t; @@ -140,7 +143,9 @@ fn check_version(config: &Config) -> Option { "update `config.toml` to use `change-id = {latest_change_id}` instead" )); - t!(fs::write(warned_id_path, id.to_string())); + if io::stdout().is_terminal() { + t!(fs::write(warned_id_path, id.to_string())); + } } } else { msg.push_str("WARNING: The `change-id` is missing in the `config.toml`. This means that you will not be able to track the major changes made to the bootstrap configurations.\n");