From 57502cfc4674a66e1967c673668bc7dea0af2ff6 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 4 May 2021 01:09:21 +0200 Subject: 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 --- web/atward/src/main.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'web/atward/src') diff --git a/web/atward/src/main.rs b/web/atward/src/main.rs index 5fe5b735ba..08fa512728 100644 --- a/web/atward/src/main.rs +++ b/web/atward/src/main.rs @@ -30,6 +30,11 @@ fn queries() -> Vec { pattern: Regex::new("^b/(?P\\d+)$").unwrap(), target: |_, captures| Some(format!("https://b.tvl.fyi/{}", &captures["bug"])), }, + // Changelists (e.g. cl/42) + Query { + pattern: Regex::new("^cl/(?P\\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,); + } } -- cgit 1.4.1