diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-06-06 17:55:32 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-06-06 19:00:49 -0600 |
commit | f6080300406a674419dba5005c76bc424df35502 (patch) | |
tree | 213a1296ee3428f1c55eda7d8e449fb05c8d967d | |
parent | bf8cb8f908c1d3939a56a3fe75781612c5168555 (diff) |
imworkingon: Add things I've submitted since last update
-rw-r--r-- | cmd/generate/forge_forgejo.go | 187 | ||||
-rw-r--r-- | cmd/generate/forge_gerrit.go | 72 | ||||
-rw-r--r-- | cmd/generate/forge_github.go | 4 | ||||
-rw-r--r-- | cmd/generate/src_contribs.go | 5 | ||||
-rw-r--r-- | imworkingon/contribs.yml | 15 | ||||
-rw-r--r-- | imworkingon/upstreams.yml | 25 |
6 files changed, 298 insertions, 10 deletions
diff --git a/cmd/generate/forge_forgejo.go b/cmd/generate/forge_forgejo.go new file mode 100644 index 0000000..7d7c8ae --- /dev/null +++ b/cmd/generate/forge_forgejo.go @@ -0,0 +1,187 @@ +package main + +import ( + "fmt" + "regexp" + "time" +) + +var reForgejoPR = regexp.MustCompile(`^https://([^/]+)/([^/?#]+)/([^/?#]+)/pulls/([0-9]+)(?:\?[^#]*)?(?:#.*)?$`) + +type Forgejo struct { + Authority string +} + +var _ Forge = Forgejo{} + +func (f Forgejo) FetchStatus(urls []string) (string, error) { + for _, u := range urls { + m := reForgejoPR.FindStringSubmatch(u) + if m == nil || m[1] != f.Authority { + continue + } + authority := m[1] + user := m[2] + repo := m[3] + prnum := m[4] + + urlStr := "https://" + authority + "/api/v1/repos/" + user + "/" + repo + "/pulls/" + prnum + + var obj struct { + // State values are "open" and "closed". + State string `json:"state"` + Merged bool `json:"merged"` + MergeCommitSha string `json:"merge_commit_sha"` + } + if err := httpGetJSON(urlStr, nil, &obj); err != nil { + return "", err + } + ret := obj.State + if obj.Merged { + ret = statusMerged + tag, err := getGitTagThatContainsAll("https://"+authority+"/"+user+"/"+repo, obj.MergeCommitSha) + if err != nil { + return "", err + } + if tag != "" { + ret = fmt.Sprintf(statusReleasedFmt, tag) + } + } + + return ret, nil + } + return "", nil +} + +func (f Forgejo) FetchSubmittedAt(urls []string) (time.Time, error) { + for _, u := range urls { + m := reForgejoPR.FindStringSubmatch(u) + fmt.Printf("u=%q m=%#v\n", u, m) + if m == nil || m[1] != f.Authority { + continue + } + authority := m[1] + user := m[2] + repo := m[3] + prnum := m[4] + + urlStr := "https://" + authority + "/api/v1/repos/" + user + "/" + repo + "/pulls/" + prnum + + var obj struct { + CreatedAt time.Time `json:"created_at"` + } + if err := httpGetJSON(urlStr, nil, &obj); err != nil { + return time.Time{}, err + } + return obj.CreatedAt, nil + } + return time.Time{}, nil +} + +func (f Forgejo) FetchLastUpdated(urls []string) (time.Time, User, error) { + for _, u := range urls { + m := reForgejoPR.FindStringSubmatch(u) + if m == nil || m[1] != f.Authority { + continue + } + authority := m[1] + user := m[2] + repo := m[3] + prnum := m[4] + + urlStr := "https://" + authority + "/api/v1/repos/" + user + "/" + repo + "/pulls/" + prnum + + var obj struct { + UpdatedAt time.Time `json:"updated_at"` + + CreatedAt time.Time `json:"created_at"` + CreatedBy struct { + Login string `json:"login"` + HTMLURL string `json:"html_url"` + } `json:"user"` + + MergedAt time.Time `json:"merged_at"` + MergedBy struct { + Login string `json:"login"` + HTMLURL string `json:"html_url"` + } `json:"merged_by"` + } + if err := httpGetJSON(urlStr, nil, &obj); err != nil { + return time.Time{}, User{}, err + } + + retUpdatedAt := obj.UpdatedAt + var retUser User + + if retUser == (User{}) && withinOneSecond(obj.CreatedAt, retUpdatedAt) { + retUser.Name = obj.CreatedBy.Login + retUser.URL = obj.CreatedBy.HTMLURL + } + if retUser == (User{}) && withinOneSecond(obj.MergedAt, retUpdatedAt) { + retUser.Name = obj.MergedBy.Login + retUser.URL = obj.MergedBy.HTMLURL + } + if retUser == (User{}) { + // "normal" comments + var comments []struct { + UpdatedAt time.Time `json:"updated_at"` + User struct { + Login string `json:"login"` + HTMLURL string `json:"html_url"` + } `json:"user"` + } + if err := httpGetPaginatedJSON("https://api.github.com/repos/"+user+"/"+repo+"/issues/"+prnum+"/comments", nil, &comments, githubPagination); err != nil { + return time.Time{}, User{}, err + } + for _, comment := range comments { + if withinOneSecond(comment.UpdatedAt, retUpdatedAt) { + retUser.Name = comment.User.Login + retUser.URL = comment.User.HTMLURL + break + } + } + } + if retUser == (User{}) { + // comments on a specific part of the diff + var reviewComments []struct { + UpdatedAt time.Time `json:"updated_at"` + User struct { + Login string `json:"login"` + HTMLURL string `json:"html_url"` + } `json:"user"` + } + if err := httpGetPaginatedJSON("https://api.github.com/repos/"+user+"/"+repo+"/pulls/"+prnum+"/comments", nil, &reviewComments, githubPagination); err != nil { + return time.Time{}, User{}, err + } + for _, comment := range reviewComments { + if withinOneSecond(comment.UpdatedAt, retUpdatedAt) { + retUser.Name = comment.User.Login + retUser.URL = comment.User.HTMLURL + break + } + } + } + if retUser == (User{}) { + var events []struct { + CreatedAt time.Time `json:"created_at"` + Actor struct { + Login string `json:"login"` + HTMLURL string `json:"html_url"` + } `json:"actor"` + } + if err := httpGetJSON("https://api.github.com/repos/"+user+"/"+repo+"/issues/"+prnum+"/events", nil, &events); err != nil { + return time.Time{}, User{}, err + } + for _, event := range events { + if withinOneSecond(event.CreatedAt, retUpdatedAt) { + retUser.Name = event.Actor.Login + retUser.URL = event.Actor.HTMLURL + break + } + } + } + + return retUpdatedAt, retUser, nil + } + return time.Time{}, User{}, nil +} diff --git a/cmd/generate/forge_gerrit.go b/cmd/generate/forge_gerrit.go index 6bdeece..1e6e073 100644 --- a/cmd/generate/forge_gerrit.go +++ b/cmd/generate/forge_gerrit.go @@ -4,6 +4,7 @@ import ( "encoding" "encoding/json" "fmt" + "net/url" "regexp" "strings" "time" @@ -58,26 +59,83 @@ type Gerrit struct{} 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 { + m := reGoogleGerritCL.FindStringSubmatch(u) + if m == nil { + continue + } + authority := m[1] + projectID := m[2] + changeID := m[3] + + urlStr := "https://" + authority + "/changes/" + url.PathEscape(projectID) + "~" + changeID + "?o=MESSAGES&o=DETAILED_ACCOUNTS" + + var obj struct { + Status string `json:"status"` + } + if err := httpGetGerritJSON(urlStr, nil, &obj); err != nil { + return "", err + } + // https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#change-info + switch obj.Status { + case "NEW": + return "open", nil + case "MERGED": + return "merged", nil + case "ABANDONED": + return "closed", 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 { + m := reGoogleGerritCL.FindStringSubmatch(u) + if m == nil { + continue + } + authority := m[1] + projectID := m[2] + changeID := m[3] + + urlStr := "https://" + authority + "/changes/" + url.PathEscape(projectID) + "~" + changeID + "?o=MESSAGES&o=DETAILED_ACCOUNTS" + + var obj struct { + Created GerritTime `json:"created"` + } + if err := httpGetGerritJSON(urlStr, nil, &obj); err != nil { + return time.Time{}, err + } + return obj.Created.Val, nil + } return time.Time{}, nil } -var reGoLangGerritCL = regexp.MustCompile(`https://go-review\.googlesource\.com/c/([^/?#]+)/\+/([0-9]+)(?:\?[^#]*)?(?:#.*)?$`) - func (Gerrit) FetchLastUpdated(urls []string) (time.Time, User, error) { for _, u := range urls { - m := reGoLangGerritCL.FindStringSubmatch(u) + m := reGoogleGerritCL.FindStringSubmatch(u) if m == nil { continue } - projectID := m[1] - changeID := m[2] + authority := m[1] + projectID := m[2] + changeID := m[3] - urlStr := "https://go-review.googlesource.com/changes/" + projectID + "~" + changeID + "?o=MESSAGES&o=DETAILED_ACCOUNTS" + urlStr := "https://" + authority + "/changes/" + url.PathEscape(projectID) + "~" + changeID + "?o=MESSAGES&o=DETAILED_ACCOUNTS" var obj struct { Updated GerritTime `json:"updated"` @@ -102,7 +160,7 @@ func (Gerrit) FetchLastUpdated(urls []string) (time.Time, User, error) { } else { retUser.Name = message.Author.Name } - retUser.URL = fmt.Sprintf("https://go-review.googlesource.com/dashboard/%d", message.Author.AccountID) + retUser.URL = fmt.Sprintf("https://%s/dashboard/%d", authority, message.Author.AccountID) break } } diff --git a/cmd/generate/forge_github.go b/cmd/generate/forge_github.go index 77a2919..d3618ce 100644 --- a/cmd/generate/forge_github.go +++ b/cmd/generate/forge_github.go @@ -90,6 +90,8 @@ func (GitHub) FetchLastUpdated(urls []string) (time.Time, User, error) { repo := m[2] prnum := m[3] + urlStr := "https://api.github.com/repos/" + user + "/" + repo + "/pulls/" + prnum + var obj struct { UpdatedAt time.Time `json:"updated_at"` @@ -105,7 +107,7 @@ func (GitHub) FetchLastUpdated(urls []string) (time.Time, User, error) { HTMLURL string `json:"html_url"` } `json:"merged_by"` } - if err := httpGetJSON("https://api.github.com/repos/"+user+"/"+repo+"/pulls/"+prnum, nil, &obj); err != nil { + if err := httpGetJSON(urlStr, nil, &obj); err != nil { return time.Time{}, User{}, err } diff --git a/cmd/generate/src_contribs.go b/cmd/generate/src_contribs.go index b5345e3..9c7bcd6 100644 --- a/cmd/generate/src_contribs.go +++ b/cmd/generate/src_contribs.go @@ -72,8 +72,8 @@ func (c *Contribution) Fill() error { return err } for _, u := range c.URLs { - if m := reGoLangGerritCL.FindStringSubmatch(u); m != nil { - c.URLs = append(c.URLs, "https://golang.org/cl/"+m[2]) + if m := reGoogleGerritCL.FindStringSubmatch(u); m != nil && m[1] == "go-review.googlesource.com" { + c.URLs = append(c.URLs, "https://golang.org/cl/"+m[3]) } } return nil @@ -111,6 +111,7 @@ var forges = []Forge{ Gerrit{}, // must be higher than GitHub because of golang GitHub{}, GitLab{}, + Forgejo{"codeberg.org"}, PiperMail{}, // lowest precedence } diff --git a/imworkingon/contribs.yml b/imworkingon/contribs.yml index 56c50ce..31cd33e 100644 --- a/imworkingon/contribs.yml +++ b/imworkingon/contribs.yml @@ -131,3 +131,18 @@ should make it easier for distros downstream of Arch (certainly Parabola, hopefully Artix) to provide init-freedom and support other init systems. +- urls: [https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/5586382] + tags: [boot] + desc: | + TODO +- urls: [https://codeberg.org/libreboot/lbmk/pulls/218] + tags: [boot] + desc: | + TODO +- urls: + - https://sourceware.org/pipermail/binutils/2024-June/134608.html + - https://sourceware.org/pipermail/gdb-patches/2024-June/209720.html + tags: [GNU] + status: open + desc: | + TODO diff --git a/imworkingon/upstreams.yml b/imworkingon/upstreams.yml index cc96eb6..bb9f14a 100644 --- a/imworkingon/upstreams.yml +++ b/imworkingon/upstreams.yml @@ -51,3 +51,28 @@ name: Go desc: | The Go programming language. +- urls: + - https://libreboot.org + - https://codeberg.org/libreboot + name: Libreboot + desc: | + Libreboot is a distribution of coreboot, a Free Software + motherboard-firmware platform. +- urls: + - https://www.gnu.org/software/binutils + - https://sourceware.org/binutils + - https://sourceware.org/pipermail/binutils + + - https://www.gnu.org/software/gdb + - https://sourceware.org/gdb + - https://sourceware.org/pipermail/gdb-patches + name: GNU Binutils / GDB + desc: | + GNU Binutils and GDB (the GNU Project Debugger) share a Git + repository. +- urls: + - https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/ # v1 & v2 + - https://chromium-review.googlesource.com/c/chromiumos/platform/vboot/ # v3 rewrite + name: vboot + desc: | + vboot is Google's Verified Boot reference implementation. |