File tree 1 file changed +15
-5
lines changed
1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change 7
7
8
8
use std:: io:: Write ;
9
9
use std:: process;
10
+ use std:: str:: FromStr ;
10
11
use std:: {
11
12
env,
12
13
fs:: { self , OpenOptions } ,
@@ -136,16 +137,25 @@ fn check_version(config: &Config) -> Option<String> {
136
137
let latest_change_id = CONFIG_CHANGE_HISTORY . last ( ) . unwrap ( ) . change_id ;
137
138
let warned_id_path = config. out . join ( "bootstrap" ) . join ( ".last-warned-change-id" ) ;
138
139
139
- if let Some ( id) = config. change_id {
140
+ if let Some ( mut id) = config. change_id {
140
141
if id == latest_change_id {
141
142
return None ;
142
143
}
143
144
144
- if let Ok ( last_warned_id) = fs:: read_to_string ( & warned_id_path) {
145
- if latest_change_id. to_string ( ) == last_warned_id {
146
- return None ;
145
+ // Always try to use `change-id` from .last-warned-change-id first. If it doesn't exist,
146
+ // then use the one from the config.toml. This way we never show the same warnings
147
+ // more than once.
148
+ if let Ok ( t) = fs:: read_to_string ( & warned_id_path) {
149
+ let last_warned_id =
150
+ usize:: from_str ( & t) . expect ( & format ! ( "{} is corrupted." , warned_id_path. display( ) ) ) ;
151
+
152
+ // We only use the last_warned_id if it exists in `CONFIG_CHANGE_HISTORY`.
153
+ // Otherwise, we may retrieve all the changes if it's not the highest value.
154
+ // For better understanding, refer to `change_tracker::find_recent_config_change_ids`.
155
+ if CONFIG_CHANGE_HISTORY . iter ( ) . any ( |config| config. change_id == last_warned_id) {
156
+ id = last_warned_id;
147
157
}
148
- }
158
+ } ;
149
159
150
160
let changes = find_recent_config_change_ids ( id) ;
151
161
You can’t perform that action at this time.
0 commit comments