Skip to content

Commit

Permalink
write .last-warned-change-id only if environment is tty
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
onur-ozkan committed Nov 11, 2023
1 parent 426a2f8 commit 89829bb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/bootstrap/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 89829bb

Please sign in to comment.