Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 1 | // Copyright 2019 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | // Package repos contains information about Go source repositories. |
| 6 | package repos |
| 7 | |
| 8 | import "fmt" |
| 9 | |
| 10 | type Repo struct { |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 11 | // GoGerritProject, if non-empty, is the repo's Gerrit project |
| 12 | // name, such as "go", "net", or "sys". |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 13 | GoGerritProject string |
| 14 | |
| 15 | // ImportPath is the repo's import path. |
Dmitri Shuralyov | 5250664 | 2020-03-06 12:29:13 -0500 | [diff] [blame] | 16 | // It is empty for the main Go repo and other repos that do not |
| 17 | // contain Go code. |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 18 | ImportPath string |
| 19 | |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 20 | // MirrorToGitHub controls whether this repo is mirrored |
| 21 | // from Gerrit to GitHub. If true, GoGerritProject and |
| 22 | // gitHubRepo must both be defined. |
| 23 | MirrorToGitHub bool |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 24 | |
Jamal Carvalho | 6cdc019 | 2021-11-03 23:33:31 +0000 | [diff] [blame] | 25 | // MirrorToCSRProject controls whether this repo is mirrored from |
| 26 | // Gerrit to Cloud Source Repositories. If not empty, GoGerritProject |
| 27 | // must be defined. It will be mirrored to a CSR repo in the given |
| 28 | // project with the same name as the Gerrit repo. |
| 29 | MirrorToCSRProject string |
Heschi Kreinick | 9477c7e | 2021-06-02 09:59:40 -0400 | [diff] [blame] | 30 | |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 31 | // showOnDashboard is whether to show the repo on the bottom |
| 32 | // of build.golang.org in the repo overview section. |
| 33 | showOnDashboard bool |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 34 | |
| 35 | // CoordinatorCanBuild reports whether this a repo that the |
| 36 | // build coordinator knows how to build. |
| 37 | CoordinatorCanBuild bool |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 38 | |
Heschi Kreinick | 27cb3d8 | 2021-06-02 17:48:15 -0400 | [diff] [blame] | 39 | // GitHubRepo is the "org/repo" of where this repo exists on |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 40 | // GitHub. If MirrorToGitHub is true, this is the |
| 41 | // destination. |
Heschi Kreinick | 27cb3d8 | 2021-06-02 17:48:15 -0400 | [diff] [blame] | 42 | GitHubRepo string |
Brad Fitzpatrick | 2440173 | 2019-12-13 16:46:49 +0000 | [diff] [blame] | 43 | |
| 44 | // WebsiteDesc is the description of the repo for showing on |
| 45 | // https://golang.org/pkg/#subrepo. |
| 46 | // It should be plain text. Hostnames may be auto-linkified. |
| 47 | WebsiteDesc string |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | // ByGerritProject maps from a Gerrit project name ("go", "net", etc) |
| 51 | // to the Repo's information. |
| 52 | var ByGerritProject = map[string]*Repo{ /* initialized below */ } |
| 53 | |
| 54 | // ByImportPath maps from an import path ("golang.org/x/net") to the |
| 55 | // Repo's information. |
| 56 | var ByImportPath = map[string]*Repo{ /* initialized below */ } |
| 57 | |
| 58 | func init() { |
Jamal Carvalho | 6cdc019 | 2021-11-03 23:33:31 +0000 | [diff] [blame] | 59 | addMirrored("go", coordinatorCanBuild, noDash, enableCSR("golang-org")) |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 60 | addMirrored("dl", importPath("golang.org/dl"), coordinatorCanBuild) |
Dmitri Shuralyov | cd15c8b | 2021-02-04 12:51:44 -0500 | [diff] [blame] | 61 | addMirrored("gddo", importPath("github.com/golang/gddo"), archivedOnGitHub) |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 62 | addMirrored("gofrontend") |
| 63 | addMirrored("proposal") |
| 64 | addMirrored("sublime-build") |
| 65 | addMirrored("sublime-config") |
| 66 | |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 67 | x("arch") |
Brad Fitzpatrick | 2440173 | 2019-12-13 16:46:49 +0000 | [diff] [blame] | 68 | x("benchmarks", desc("benchmarks to measure Go as it is developed")) |
Dmitri Shuralyov | 8adac88 | 2021-06-02 19:29:35 -0400 | [diff] [blame] | 69 | x("blog", noDash) |
Brad Fitzpatrick | 2440173 | 2019-12-13 16:46:49 +0000 | [diff] [blame] | 70 | x("build", desc("build.golang.org's implementation")) |
| 71 | x("crypto", desc("additional cryptography packages")) |
| 72 | x("debug", desc("an experimental debugger for Go")) |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 73 | x("example", noDash) |
Brad Fitzpatrick | 2440173 | 2019-12-13 16:46:49 +0000 | [diff] [blame] | 74 | x("exp", desc("experimental and deprecated packages (handle with care; may change without warning)")) |
| 75 | x("image", desc("additional imaging packages")) |
Daniel Martà | 58cc22b | 2021-05-08 22:34:43 +0100 | [diff] [blame] | 76 | x("lint", noDash, archivedOnGitHub) |
Brad Fitzpatrick | 2440173 | 2019-12-13 16:46:49 +0000 | [diff] [blame] | 77 | x("mobile", desc("experimental support for Go on mobile platforms")) |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 78 | x("mod") |
Brad Fitzpatrick | 2440173 | 2019-12-13 16:46:49 +0000 | [diff] [blame] | 79 | x("net", desc("additional networking packages")) |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 80 | x("oauth2") |
Brad Fitzpatrick | 2440173 | 2019-12-13 16:46:49 +0000 | [diff] [blame] | 81 | x("perf", desc("packages and tools for performance measurement, storage, and analysis")) |
Jamal Carvalho | cca7345 | 2021-11-03 23:36:05 +0000 | [diff] [blame] | 82 | x("pkgsite", desc("home of the pkg.go.dev website"), noBuildAndNoDash, enableCSR("go-discovery")) |
Jamal Carvalho | 6cdc019 | 2021-11-03 23:33:31 +0000 | [diff] [blame] | 83 | x("playground", noDash, enableCSR("golang-org")) |
Brad Fitzpatrick | 2440173 | 2019-12-13 16:46:49 +0000 | [diff] [blame] | 84 | x("review", desc("a tool for working with Gerrit code reviews")) |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 85 | x("scratch", noDash) |
Brad Fitzpatrick | 2440173 | 2019-12-13 16:46:49 +0000 | [diff] [blame] | 86 | x("sync", desc("additional concurrency primitives")) |
| 87 | x("sys", desc("packages for making system calls")) |
Dmitri Shuralyov | 0e19172 | 2021-11-23 10:46:45 -0500 | [diff] [blame] | 88 | x("talks", noDash) |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 89 | x("term") |
Brad Fitzpatrick | 2440173 | 2019-12-13 16:46:49 +0000 | [diff] [blame] | 90 | x("text", desc("packages for working with text")) |
| 91 | x("time", desc("additional time packages")) |
| 92 | x("tools", desc("godoc, goimports, gorename, and other tools")) |
Dmitri Shuralyov | 8adac88 | 2021-06-02 19:29:35 -0400 | [diff] [blame] | 93 | x("tour", noDash) |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 94 | x("vgo", noDash) |
Julie Qiu | c046fca | 2021-11-01 15:34:42 -0400 | [diff] [blame] | 95 | x("vuln", desc("code for the Go Vulnerability Database")) |
Jamal Carvalho | 6cdc019 | 2021-11-03 23:33:31 +0000 | [diff] [blame] | 96 | x("vulndb", desc("reports for the Go Vulnerability Database"), enableCSR("golang-org")) |
| 97 | x("website", desc("home of the golang.org and go.dev websites"), enableCSR("golang-org")) |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 98 | x("xerrors", noDash) |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 99 | |
| 100 | add(&Repo{GoGerritProject: "gollvm"}) |
| 101 | add(&Repo{GoGerritProject: "grpc-review"}) |
| 102 | |
| 103 | add(&Repo{ |
| 104 | GoGerritProject: "protobuf", |
| 105 | MirrorToGitHub: true, |
Dmitri Shuralyov | c6b82d5 | 2020-03-02 15:15:29 -0500 | [diff] [blame] | 106 | ImportPath: "google.golang.org/protobuf", |
Heschi Kreinick | 27cb3d8 | 2021-06-02 17:48:15 -0400 | [diff] [blame] | 107 | GitHubRepo: "protocolbuffers/protobuf-go", |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 108 | }) |
Dmitri Shuralyov | 5250664 | 2020-03-06 12:29:13 -0500 | [diff] [blame] | 109 | |
| 110 | add(&Repo{ |
| 111 | GoGerritProject: "vscode-go", |
| 112 | MirrorToGitHub: true, |
Heschi Kreinick | 27cb3d8 | 2021-06-02 17:48:15 -0400 | [diff] [blame] | 113 | GitHubRepo: "golang/vscode-go", |
Dmitri Shuralyov | 5250664 | 2020-03-06 12:29:13 -0500 | [diff] [blame] | 114 | }) |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | type modifyRepo func(*Repo) |
| 118 | |
| 119 | // noDash is an option to the x func that marks the repo as hidden on |
| 120 | // the https://build.golang.org/ dashboard. |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 121 | func noDash(r *Repo) { r.showOnDashboard = false } |
| 122 | |
Dmitri Shuralyov | fd3ecdd | 2020-03-09 21:22:09 +0000 | [diff] [blame] | 123 | func noBuildAndNoDash(r *Repo) { r.CoordinatorCanBuild, r.showOnDashboard = false, false } |
| 124 | |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 125 | func coordinatorCanBuild(r *Repo) { r.CoordinatorCanBuild = true } |
| 126 | |
Dmitri Shuralyov | cd15c8b | 2021-02-04 12:51:44 -0500 | [diff] [blame] | 127 | func archivedOnGitHub(r *Repo) { |
| 128 | // When a repository is archived on GitHub, trying to push |
| 129 | // to it will fail. So don't mirror. |
| 130 | r.MirrorToGitHub = false |
| 131 | } |
| 132 | |
Jamal Carvalho | 6cdc019 | 2021-11-03 23:33:31 +0000 | [diff] [blame] | 133 | func enableCSR(p string) modifyRepo { return func(r *Repo) { r.MirrorToCSRProject = p } } |
Heschi Kreinick | c542112 | 2021-06-03 16:43:04 -0400 | [diff] [blame] | 134 | |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 135 | func importPath(v string) modifyRepo { return func(r *Repo) { r.ImportPath = v } } |
| 136 | |
Brad Fitzpatrick | 2440173 | 2019-12-13 16:46:49 +0000 | [diff] [blame] | 137 | func desc(v string) modifyRepo { return func(r *Repo) { r.WebsiteDesc = v } } |
| 138 | |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 139 | // addMirrored adds a repo that's on Gerrit and mirrored to GitHub. |
| 140 | func addMirrored(proj string, opts ...modifyRepo) { |
| 141 | repo := &Repo{ |
| 142 | GoGerritProject: proj, |
| 143 | MirrorToGitHub: true, |
Heschi Kreinick | 27cb3d8 | 2021-06-02 17:48:15 -0400 | [diff] [blame] | 144 | GitHubRepo: "golang/" + proj, |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 145 | } |
| 146 | for _, o := range opts { |
| 147 | o(repo) |
| 148 | } |
| 149 | add(repo) |
| 150 | } |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 151 | |
| 152 | // x adds a golang.org/x repo. |
| 153 | func x(proj string, opts ...modifyRepo) { |
| 154 | repo := &Repo{ |
| 155 | GoGerritProject: proj, |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 156 | MirrorToGitHub: true, |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 157 | CoordinatorCanBuild: true, |
| 158 | ImportPath: "golang.org/x/" + proj, |
Heschi Kreinick | 27cb3d8 | 2021-06-02 17:48:15 -0400 | [diff] [blame] | 159 | GitHubRepo: "golang/" + proj, |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 160 | showOnDashboard: true, |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 161 | } |
| 162 | for _, o := range opts { |
| 163 | o(repo) |
| 164 | } |
| 165 | add(repo) |
| 166 | } |
| 167 | |
| 168 | func add(r *Repo) { |
Jamal Carvalho | 6cdc019 | 2021-11-03 23:33:31 +0000 | [diff] [blame] | 169 | if (r.MirrorToCSRProject != "" || r.MirrorToGitHub || r.showOnDashboard) && r.GoGerritProject == "" { |
Heschi Kreinick | 9477c7e | 2021-06-02 09:59:40 -0400 | [diff] [blame] | 170 | panic(fmt.Sprintf("project %+v sets feature(s) that require a GoGerritProject, but has none", r)) |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 171 | } |
Heschi Kreinick | 27cb3d8 | 2021-06-02 17:48:15 -0400 | [diff] [blame] | 172 | if r.MirrorToGitHub && r.GitHubRepo == "" { |
Heschi Kreinick | 9477c7e | 2021-06-02 09:59:40 -0400 | [diff] [blame] | 173 | panic(fmt.Sprintf("project %+v has MirrorToGitHub but no gitHubRepo", r)) |
| 174 | } |
| 175 | if r.showOnDashboard && !r.CoordinatorCanBuild { |
| 176 | panic(fmt.Sprintf("project %+v is showOnDashboard but not marked buildable by coordinator", r)) |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 177 | } |
| 178 | |
Brad Fitzpatrick | e2b9141 | 2019-11-25 06:11:04 +0000 | [diff] [blame] | 179 | if p := r.GoGerritProject; p != "" { |
| 180 | if _, dup := ByGerritProject[p]; dup { |
| 181 | panic(fmt.Sprintf("duplicate Gerrit project %q in %+v", p, r)) |
| 182 | } |
| 183 | ByGerritProject[p] = r |
| 184 | } |
| 185 | if p := r.ImportPath; p != "" { |
| 186 | if _, dup := ByImportPath[p]; dup { |
| 187 | panic(fmt.Sprintf("duplicate import path %q in %+v", p, r)) |
| 188 | } |
| 189 | ByImportPath[p] = r |
| 190 | } |
| 191 | } |
Brad Fitzpatrick | 6e1808a | 2019-12-09 06:08:22 +0000 | [diff] [blame] | 192 | |
| 193 | // ShowOnDashboard reports whether this repo should show up on build.golang.org |
| 194 | // in the list of repos at bottom. |
| 195 | // |
| 196 | // When this returns true, r.GoGerritProject is guaranteed to be non-empty. |
| 197 | func (r *Repo) ShowOnDashboard() bool { return r.showOnDashboard } |