@@ -105,18 +105,27 @@ pub fn check(root_path: &Path, bless: bool, bad: &mut bool) {
105
105
106
106
// the list of files in ui tests that are allowed to start with `issue-XXXX`
107
107
// BTreeSet because we would like a stable ordering so --bless works
108
- let issues_list =
109
- include ! ( "issues.txt" ) . map ( |path| path. replace ( "/" , std:: path:: MAIN_SEPARATOR_STR ) ) ;
110
- let issues: Vec < String > = Vec :: from ( issues_list. clone ( ) ) ;
111
- let is_sorted = issues. windows ( 2 ) . all ( |w| w[ 0 ] < w[ 1 ] ) ;
108
+ let mut prev_line = String :: new ( ) ;
109
+ let mut is_sorted = true ;
110
+ let allowed_issue_names: BTreeSet < _ > = include_str ! ( "issues.txt" )
111
+ . lines ( )
112
+ . map ( |line| {
113
+ if * prev_line > * line {
114
+ is_sorted = false ;
115
+ }
116
+
117
+ prev_line = line. to_string ( ) ;
118
+ line. to_string ( )
119
+ } )
120
+ . collect ( ) ;
121
+
112
122
if !is_sorted && !bless {
113
123
tidy_error ! (
114
124
bad,
115
125
"`src/tools/tidy/src/issues.txt` is not in order, mostly because you modified it manually,
116
126
please only update it with command `x test tidy --bless`"
117
127
) ;
118
128
}
119
- let allowed_issue_names = BTreeSet :: from ( issues_list) ;
120
129
121
130
let mut remaining_issue_names: BTreeSet < String > = allowed_issue_names. clone ( ) ;
122
131
@@ -186,29 +195,19 @@ pub fn check(root_path: &Path, bless: bool, bad: &mut bool) {
186
195
// if there are any file names remaining, they were moved on the fs.
187
196
// our data must remain up to date, so it must be removed from issues.txt
188
197
// do this automatically on bless, otherwise issue a tidy error
189
- if bless && !remaining_issue_names. is_empty ( ) {
190
- let issues_txt_header = r#"
191
- /*
192
- ============================================================
193
- ⚠️⚠️⚠️NOTHING SHOULD EVER BE ADDED TO THIS LIST⚠️⚠️⚠️
194
- ============================================================
195
- */
196
- [
197
- "# ;
198
+ if bless && ( !remaining_issue_names. is_empty ( ) || !is_sorted) {
198
199
let tidy_src = root_path. join ( "src/tools/tidy/src" ) ;
199
200
// instead of overwriting the file, recreate it and use an "atomic rename"
200
201
// so we don't bork things on panic or a contributor using Ctrl+C
201
202
let blessed_issues_path = tidy_src. join ( "issues_blessed.txt" ) ;
202
203
let mut blessed_issues_txt = fs:: File :: create ( & blessed_issues_path) . unwrap ( ) ;
203
- blessed_issues_txt. write ( issues_txt_header. as_bytes ( ) ) . unwrap ( ) ;
204
204
// If we changed paths to use the OS separator, reassert Unix chauvinism for blessing.
205
205
for filename in allowed_issue_names
206
206
. difference ( & remaining_issue_names)
207
207
. map ( |s| s. replace ( std:: path:: MAIN_SEPARATOR_STR , "/" ) )
208
208
{
209
- write ! ( blessed_issues_txt, "\" {filename}\" , \n " ) . unwrap ( ) ;
209
+ writeln ! ( blessed_issues_txt, "{filename}" ) . unwrap ( ) ;
210
210
}
211
- write ! ( blessed_issues_txt, "]\n " ) . unwrap ( ) ;
212
211
let old_issues_path = tidy_src. join ( "issues.txt" ) ;
213
212
fs:: rename ( blessed_issues_path, old_issues_path) . unwrap ( ) ;
214
213
} else {
0 commit comments