check-issue-refs: catch full forge issue URLs too, drop internal links from docs entirely
This commit is contained in:
parent
e1e913015d
commit
a4f72365c7
22 changed files with 59 additions and 80 deletions
|
|
@ -109,7 +109,7 @@ pub fn mark_read_best_effort(client: &Client, repo: &str, number: u64) {
|
|||
|
||||
/// True when a notification `subject.url` refers to issue/PR `number` in
|
||||
/// the (already repo-scoped) query. Forgejo subject URLs end in the
|
||||
/// issue/PR number (`…/repos/o/r/issues/42`, or `…/pulls/42`); match the
|
||||
/// issue/PR number (an `/issues/<n>` or `/pulls/<n>` path); match the
|
||||
/// trailing path segment. Tolerates a trailing slash.
|
||||
#[must_use]
|
||||
pub fn subject_matches(subject_url: &str, number: u64) -> bool {
|
||||
|
|
@ -137,7 +137,7 @@ mod tests {
|
|||
"pinned": false,
|
||||
"subject": {
|
||||
"title": "whatever",
|
||||
"url": "https://forge/api/v1/repos/o/r/issues/7",
|
||||
"url": "https://forge/api/v1/repos/o/r/issues/7", // lint:allow: test fixture, not a real forge link
|
||||
"type": "SomeFutureSubjectTypeWeDoNotKnow"
|
||||
},
|
||||
"some_new_field": { "nested": 1 }
|
||||
|
|
@ -148,7 +148,7 @@ mod tests {
|
|||
assert_eq!(ns[0].id, Some(42));
|
||||
assert_eq!(
|
||||
ns[0].subject.as_ref().and_then(|s| s.url.as_deref()),
|
||||
Some("https://forge/api/v1/repos/o/r/issues/7")
|
||||
Some("https://forge/api/v1/repos/o/r/issues/7") // lint:allow: test fixture, not a real forge link
|
||||
);
|
||||
assert_eq!(ns[1].id, Some(43));
|
||||
assert!(ns[1].subject.is_none());
|
||||
|
|
@ -157,7 +157,7 @@ mod tests {
|
|||
#[test]
|
||||
fn matches_issue_subject_url() {
|
||||
assert!(subject_matches(
|
||||
"https://forge/api/v1/repos/o/r/issues/42",
|
||||
"https://forge/api/v1/repos/o/r/issues/42", // lint:allow: test fixture, not a real forge link
|
||||
42
|
||||
));
|
||||
}
|
||||
|
|
@ -170,7 +170,7 @@ mod tests {
|
|||
#[test]
|
||||
fn tolerates_trailing_slash() {
|
||||
assert!(subject_matches(
|
||||
"https://forge/api/v1/repos/o/r/issues/9/",
|
||||
"https://forge/api/v1/repos/o/r/issues/9/", // lint:allow: test fixture, not a real forge link
|
||||
9
|
||||
));
|
||||
}
|
||||
|
|
@ -178,7 +178,7 @@ mod tests {
|
|||
#[test]
|
||||
fn rejects_different_number() {
|
||||
assert!(!subject_matches(
|
||||
"https://forge/api/v1/repos/o/r/issues/42",
|
||||
"https://forge/api/v1/repos/o/r/issues/42", // lint:allow: test fixture, not a real forge link
|
||||
7
|
||||
));
|
||||
}
|
||||
|
|
@ -192,7 +192,7 @@ mod tests {
|
|||
fn rejects_substring_number() {
|
||||
// 142 must not match 42 — full-segment parse, not substring.
|
||||
assert!(!subject_matches(
|
||||
"https://forge/api/v1/repos/o/r/issues/142",
|
||||
"https://forge/api/v1/repos/o/r/issues/142", // lint:allow: test fixture, not a real forge link
|
||||
42
|
||||
));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue