File tree 3 files changed +20
-5
lines changed
3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -38,8 +38,8 @@ impl fmt::Display for Date {
38
38
39
39
fn make_date_regex ( ) -> Vec < Regex > {
40
40
let patterns = [
41
- r"<!--\s+date-check:\s+(\w +)\s+(\d+ {4})\s+-->" ,
42
- r"<!--\s+date-check\s+-->\s+(\w +)\s+(\d+ {4})" ,
41
+ r"<!--\s+date-check:\s+(\D +)\s+(\d{4})\s+-->" ,
42
+ r"<!--\s+date-check\s+-->\s+(\D +)\s+(\d{4})\b " ,
43
43
] ;
44
44
let set = RegexSet :: new ( & patterns) . unwrap ( ) ;
45
45
set. patterns ( )
@@ -198,6 +198,20 @@ mod tests {
198
198
assert ! ( regexes[ 1 ] . is_match( "<!-- date-check --> january 2021" ) ) ;
199
199
assert ! ( regexes[ 1 ] . is_match( "<!-- date-check --> Jan 2021" ) ) ;
200
200
assert ! ( regexes[ 1 ] . is_match( "<!-- date-check --> January 2021" ) ) ;
201
+
202
+ assert ! ( regexes[ 1 ] . is_match( "<!-- date-check --> jan 2021 " ) ) ;
203
+ assert ! ( regexes[ 1 ] . is_match( "<!-- date-check --> jan 2021." ) ) ;
204
+ }
205
+
206
+ #[ test]
207
+ fn test_date_regex_fail ( ) {
208
+ let regexes = & make_date_regex ( ) ;
209
+ assert ! ( !regexes[ 0 ] . is_match( "<!-- date-check: jan 221 -->" ) ) ;
210
+ assert ! ( !regexes[ 0 ] . is_match( "<!-- date-check: jan 20221 -->" ) ) ;
211
+ assert ! ( !regexes[ 0 ] . is_match( "<!-- date-check: 01 2021 -->" ) ) ;
212
+ assert ! ( !regexes[ 1 ] . is_match( "<!-- date-check --> jan 221" ) ) ;
213
+ assert ! ( !regexes[ 1 ] . is_match( "<!-- date-check --> jan 20222" ) ) ;
214
+ assert ! ( !regexes[ 1 ] . is_match( "<!-- date-check --> 01 2021" ) ) ;
201
215
}
202
216
203
217
#[ test]
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ You can also install the hook as a step of running `./x.py setup`!
22
22
a file. By default, ` rust-analyzer ` runs the ` cargo check ` and ` rustfmt `
23
23
commands, but you can override these commands to use more adapted versions
24
24
of these tools when hacking on ` rustc ` . For example, for Visual Studio Code,
25
- you can write: <!-- date: 2022-04 --> <!-- the date comment is for the edition below -->
25
+ you can write: <!-- date-check: apr 2022 --> <!-- the date comment is for the edition below -->
26
26
27
27
``` JSON
28
28
{
Original file line number Diff line number Diff line change @@ -447,9 +447,10 @@ Just a few things to keep in mind:
447
447
There is a CI action (in "~ /.github/workflows/date-check.yml")
448
448
that generates a monthly issue with any of these that are over 6 months old.
449
449
450
- For the action to pick the date, add this annotation:
450
+ For the action to pick the date,
451
+ add a special annotation before specifying the date:
451
452
452
- <!-- date-check -->
453
+ <!-- date-check --> Jul 2022
453
454
454
455
Example:
455
456
You can’t perform that action at this time.
0 commit comments