From 71b547e969c1fd96edc0a05a8c185f16c2d3ed0e Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Wed, 24 Apr 2024 16:23:01 -0600 Subject: imworkingon: automatically include short URLs for golang CLs --- cmd/generate/src_contribs.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cmd/generate/src_contribs.go b/cmd/generate/src_contribs.go index 5d34fef..bbb87a6 100644 --- a/cmd/generate/src_contribs.go +++ b/cmd/generate/src_contribs.go @@ -67,6 +67,11 @@ func (c *Contribution) Fill() error { if err != nil { return err } + for _, u := range c.URLs { + if m := reGoLangGerritCL.FindStringSubmatch(u); m != nil { + c.URLs = append(c.URLs, "https://golang.org/cl/"+m[1]) + } + } return nil } @@ -86,10 +91,11 @@ func classifyStatus(status string) (string, error) { } var ( - reGitHubPR = regexp.MustCompile(`^https://github.com/([^/?#]+)/([^/?#]+)/pull/([0-9]+)(?:\?[^#]*)?(?:#.*)?$`) - reGitHubCommit = regexp.MustCompile(`^https://github.com/([^/?#]+)/([^/?#]+)/commit/([0-9a-f]+)(?:\?[^#]*)?(?:#.*)?$`) - reGitLabMR = regexp.MustCompile(`^https://([^/]+)/([^?#]+)/-/merge_requests/([0-9]+)(?:\?[^#]*)?(?:#.*)?$`) - rePiperMailDate = regexp.MustCompile(`^\s*([^<]+)\s*$`) + reGoLangGerritCL = regexp.MustCompile(`https://go-review\.googlesource\.com/c/[^/?#]+/\+/([0-9]+)(?:\?[^#]*)?(?:#.*)?$`) + reGitHubPR = regexp.MustCompile(`^https://github\.com/([^/?#]+)/([^/?#]+)/pull/([0-9]+)(?:\?[^#]*)?(?:#.*)?$`) + reGitHubCommit = regexp.MustCompile(`^https://github\.com/([^/?#]+)/([^/?#]+)/commit/([0-9a-f]+)(?:\?[^#]*)?(?:#.*)?$`) + reGitLabMR = regexp.MustCompile(`^https://([^/]+)/([^?#]+)/-/merge_requests/([0-9]+)(?:\?[^#]*)?(?:#.*)?$`) + rePiperMailDate = regexp.MustCompile(`^\s*([^<]+)\s*$`) ) const ( -- cgit v1.2.3