app/appengine: hide release-branch-only builders when viewing master branch

This is a follow-up to CL 199800. That change started to consider more
builders as active to allow release-branch-only builders to run.

However, it also made those builders show up as new empty columns when
viewing builds for the master branch. There are quite a few old FreeBSD
builders that only run on release-branch.go1.12, and it's too disruptive
to have them appear everywhere. So, hide them when viewing the master
branch of Go repo in the UI.

There can be more UI improvements to be made, and this can become too
much of a whack-a-mole to address them one by one. The scope of this CL
is to fix the most disruptive high priority problem for now. Further
improvements will happen later, with merging of app/appengine and
cmd/coordinator codebases in mind.

Updates golang/go#34738
Updates golang/go#34744

Change-Id: I3df75f8b2bbd5f6fe8097c181ee8a1b1b4354dc9
Reviewed-on: https://go-review.googlesource.com/c/build/+/199878
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/app/appengine/ui.go b/app/appengine/ui.go
index 3128912..1b788d0 100644
--- a/app/appengine/ui.go
+++ b/app/appengine/ui.go
@@ -178,6 +178,12 @@
 		return
 	}
 
+	// In the UI, when viewing the master branch of the main
+	// Go repository, hide builders that aren't active on it.
+	if repo == "" && branch == "master" {
+		data.Builders = onlyGoMasterBuilders(data.Builders)
+	}
+
 	// Populate building URLs for the HTML UI only.
 	data.populateBuildingURLs(c)
 
@@ -206,7 +212,7 @@
 	return
 }
 
-// failuresHandler is https://build.golang.org/?mode=failures , where it outputs
+// failuresHandler is https://build.golang.org/?mode=failures, where it outputs
 // one line per failure on the front page, in the form:
 //    hash builder failure-url
 func failuresHandler(w http.ResponseWriter, r *http.Request, data *uiTemplateData) {
@@ -400,6 +406,20 @@
 	return
 }
 
+// onlyGoMasterBuilders returns a subset of all builders that are
+// configured to do post-submit builds on master branch of Go repo.
+func onlyGoMasterBuilders(all []string) []string {
+	var goMaster []string
+	for _, name := range all {
+		bc, ok := dashboard.Builders[name]
+		if !ok || !bc.BuildsRepoPostSubmit("go", "master", "master") {
+			continue
+		}
+		goMaster = append(goMaster, name)
+	}
+	return goMaster
+}
+
 // builderOrder implements sort.Interface, sorting builder names
 // ("darwin-amd64", etc) first by builderPriority and then alphabetically.
 type builderOrder []string