feat(atward): Add query for changelists

Adds a query for things like cl/42

Change-Id: I144ee25c0f2c9956c81b349d653c5fec42602f9f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3092
Tested-by: BuildkiteCI
Reviewed-by: eta <eta@theta.eu.org>
This commit is contained in:
Vincent Ambo 2021-05-04 01:09:21 +02:00 committed by tazjin
parent 47986fdc21
commit 57502cfc46

View file

@ -30,6 +30,11 @@ fn queries() -> Vec<Query> {
pattern: Regex::new("^b/(?P<bug>\\d+)$").unwrap(),
target: |_, captures| Some(format!("https://b.tvl.fyi/{}", &captures["bug"])),
},
// Changelists (e.g. cl/42)
Query {
pattern: Regex::new("^cl/(?P<cl>\\d+)$").unwrap(),
target: |_, captures| Some(format!("https://cl.tvl.fyi/{}", &captures["cl"])),
},
]
}
@ -80,4 +85,15 @@ mod tests {
assert_eq!(dispatch(&queries(), "something only mentioning b/42"), None,);
assert_eq!(dispatch(&queries(), "b/invalid"), None,);
}
#[test]
fn cl_query() {
assert_eq!(
dispatch(&queries(), "cl/42"),
Some("https://cl.tvl.fyi/42".to_string())
);
assert_eq!(dispatch(&queries(), "something only mentioning cl/42"), None,);
assert_eq!(dispatch(&queries(), "cl/invalid"), None,);
}
}