summaryrefslogtreecommitdiff
path: root/cmd/generate/forge_gerrit.go
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-06-10 11:31:53 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-06-10 11:31:53 -0600
commit290354461422fff8c05ef9ce37ba154641e3f8fc (patch)
tree505e4faa4d6fba1e7d0b4addbda39a4e5beb26fd /cmd/generate/forge_gerrit.go
parent81c8d44fba88dbb049c48363d6b7697224b98a2e (diff)
imworkingon: Fuss with forge precedence
Diffstat (limited to 'cmd/generate/forge_gerrit.go')
-rw-r--r--cmd/generate/forge_gerrit.go32
1 files changed, 10 insertions, 22 deletions
diff --git a/cmd/generate/forge_gerrit.go b/cmd/generate/forge_gerrit.go
index 1e6e073..31f2256 100644
--- a/cmd/generate/forge_gerrit.go
+++ b/cmd/generate/forge_gerrit.go
@@ -62,15 +62,10 @@ var _ Forge = Gerrit{}
var reGoogleGerritCL = regexp.MustCompile(`https://([a-z]+-review\.googlesource\.com)/c/([^?#]+)/\+/([0-9]+)(?:\?[^#]*)?(?:#.*)?$`)
func (Gerrit) FetchStatus(urls []string) (string, error) {
- for _, u := range urls {
- if reGitHubPR.MatchString(u) {
- return "", nil
- }
- }
- for _, u := range urls {
+ return fetchPerURLStatus(urls, func(u string) (string, error) {
m := reGoogleGerritCL.FindStringSubmatch(u)
if m == nil {
- continue
+ return "", nil
}
authority := m[1]
projectID := m[2]
@@ -93,20 +88,15 @@ func (Gerrit) FetchStatus(urls []string) (string, error) {
case "ABANDONED":
return "closed", nil
}
- }
- return "", nil
+ return "", nil
+ })
}
func (Gerrit) FetchSubmittedAt(urls []string) (time.Time, error) {
- for _, u := range urls {
- if reGitHubPR.MatchString(u) {
- return time.Time{}, nil
- }
- }
- for _, u := range urls {
+ return fetchPerURLSubmittedAt(urls, func(u string) (time.Time, error) {
m := reGoogleGerritCL.FindStringSubmatch(u)
if m == nil {
- continue
+ return time.Time{}, nil
}
authority := m[1]
projectID := m[2]
@@ -121,15 +111,14 @@ func (Gerrit) FetchSubmittedAt(urls []string) (time.Time, error) {
return time.Time{}, err
}
return obj.Created.Val, nil
- }
- return time.Time{}, nil
+ })
}
func (Gerrit) FetchLastUpdated(urls []string) (time.Time, User, error) {
- for _, u := range urls {
+ return fetchPerURLLastUpdated(urls, func(u string) (time.Time, User, error) {
m := reGoogleGerritCL.FindStringSubmatch(u)
if m == nil {
- continue
+ return time.Time{}, User{}, nil
}
authority := m[1]
projectID := m[2]
@@ -165,6 +154,5 @@ func (Gerrit) FetchLastUpdated(urls []string) (time.Time, User, error) {
}
}
return retUpdatedAt, retUser, nil
- }
- return time.Time{}, User{}, nil
+ })
}