Skip to content

Commit

Permalink
cmd/fetchlogs: fetch repo data using the 'repo' query param
Browse files Browse the repository at this point in the history
The repo flag for fetchlogs is not currently that useful because it
queries the main Go dashboard data, which only has a few commits for
each subrepo. This was probably because the data at
  https://build.golang.org/?repo=<import path>&mode=json
was incorrect due to golang/go#35515.

With golang.org/cl/232897, this data should be corrected. Update
fetchlogs to now query data from the subrepo dashboard.

Change-Id: I352662abf7da6abb7bc23888b11e03927f567cab
Reviewed-on: https://go-review.googlesource.com/c/build/+/232898
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
  • Loading branch information
findleyr committed May 18, 2020
1 parent 8e9a669 commit 00a957a
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions cmd/fetchlogs/fetchlogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,24 @@ import (
"io"
"log"
"net/http"
"net/url"
"os"
"path/filepath"
"sync"
"time"

"golang.org/x/build/repos"
"golang.org/x/build/types"
)

var defaultDir = filepath.Join(xdgCacheDir(), "fetchlogs")

var (
flagN = flag.Int("n", 300, "limit to most recent `N` commits")
flagPar = flag.Int("j", 5, "number of concurrent download `jobs`")
flagDir = flag.String("dir", defaultDir, "`directory` to save logs to")
flagRepo = flag.String("repo", "go", `repo to fetch logs for`)
flagN = flag.Int("n", 300, "limit to most recent `N` commits")
flagPar = flag.Int("j", 5, "number of concurrent download `jobs`")
flagDir = flag.String("dir", defaultDir, "`directory` to save logs to")
flagRepo = flag.String("repo", "go", `repo to fetch logs for`)
flagDashboard = flag.String("dashboard", "https://build.golang.org", `the dashboard root url`)
)

func main() {
Expand Down Expand Up @@ -82,8 +85,15 @@ func main() {
// Fetch dashboard pages.
haveCommits := 0
for page := 0; haveCommits < *flagN; page++ {
url := fmt.Sprintf("https://build.golang.org/?mode=json&page=%d", page)
index, err := fetcher.get(url)
dashURL := fmt.Sprintf("%s/?mode=json&page=%d", *flagDashboard, page)
if *flagRepo != "go" {
repo := repos.ByGerritProject[*flagRepo]
if repo == nil {
log.Fatalf("unknown repo %s", *flagRepo)
}
dashURL += "&repo=" + url.QueryEscape(repo.ImportPath)
}
index, err := fetcher.get(dashURL)
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 00a957a

Please sign in to comment.