about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authoronur-ozkan <work@onurozkan.dev>2023-11-11 21:29:32 +0300
committeronur-ozkan <work@onurozkan.dev>2023-11-12 13:31:20 +0300
commit9a6afd0362acee1ee9685f50e6c5286a19baf6d9 (patch)
tree8c9838a6dba2c91565f077213f9b2b021854c9b5 /src/bootstrap
parent06f6cd95beca124a54a7346ea2e31b75e1bcfc5a (diff)
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 <work@onurozkan.dev>
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/src/bin/main.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/bootstrap/src/bin/main.rs b/src/bootstrap/src/bin/main.rs
index eb3fa0783a1..35010bea818 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<String> {
                 "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");