Skip to content

Commit 3faf82c

Browse files
committed
address review comment
rust-lang#1394 (comment) This led to a more robust regex, though making the tool more picky. It also found a wrong date format that was missed.
1 parent df6b805 commit 3faf82c

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

Diff for: ci/date-check/src/main.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ impl fmt::Display for Date {
3838

3939
fn make_date_regex() -> Vec<Regex> {
4040
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",
4343
];
4444
let set = RegexSet::new(&patterns).unwrap();
4545
set.patterns()
@@ -198,6 +198,20 @@ mod tests {
198198
assert!(regexes[1].is_match("<!-- date-check --> january 2021"));
199199
assert!(regexes[1].is_match("<!-- date-check --> Jan 2021"));
200200
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"));
201215
}
202216

203217
#[test]

Diff for: src/building/suggested.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ You can also install the hook as a step of running `./x.py setup`!
2222
a file. By default, `rust-analyzer` runs the `cargo check` and `rustfmt`
2323
commands, but you can override these commands to use more adapted versions
2424
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 -->
2626

2727
```JSON
2828
{

Diff for: src/contributing.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,10 @@ Just a few things to keep in mind:
447447
There is a CI action (in "~/.github/workflows/date-check.yml")
448448
that generates a monthly issue with any of these that are over 6 months old.
449449

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:
451452

452-
<!-- date-check -->
453+
<!-- date-check --> Jul 2022
453454

454455
Example:
455456

0 commit comments

Comments
 (0)