diff options
Diffstat (limited to 'cmd/generate/forge_gerrit.go')
-rw-r--r-- | cmd/generate/forge_gerrit.go | 32 |
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 + }) } |