feat: skip breaking changes notification with env var (#659)

* feat: skip breaking changes notification with env var

* ci: apply that env in ci
This commit is contained in:
SteveLauC
2024-01-23 14:50:35 +08:00
committed by GitHub
parent f9a35c7661
commit f794329913
3 changed files with 20 additions and 5 deletions

View File

@@ -12,6 +12,7 @@ use crate::XDG_DIRS;
use color_eyre::eyre::Result;
use etcetera::base_strategy::BaseStrategy;
use std::{
env::var,
fs::{read_to_string, OpenOptions},
io::Write,
path::PathBuf,
@@ -89,6 +90,16 @@ fn keep_file_path() -> PathBuf {
data_dir().join(keep_file)
}
/// If environment variable `TOPGRADE_SKIP_BRKC_NOTIFY` is set to `true`, then
/// we won't notify the user of the breaking changes.
pub(crate) fn should_skip() -> bool {
if let Ok(var) = var("TOPGRADE_SKIP_BRKC_NOTIFY") {
return var.as_str() == "true";
}
false
}
/// True if this is the first execution of a major release.
pub(crate) fn first_run_of_major_release() -> Result<bool> {
let version = VERSION_STR.parse::<Version>().expect("should be a valid version");