app/appengine: don't exclude release-branch-only builders

The filtering of builders in commitBuilders was too strict,
causing post-submit builders that are configured to run on
release-branches only to not get included in the list of
builders.

This change makes the following builders no longer skipped:

	darwin-amd64-10_10
	freebsd-386-10_3
	freebsd-386-10_4
	freebsd-386-11_1
	freebsd-amd64-10_3
	freebsd-amd64-10_4
	freebsd-amd64-11_1
	nacl-386
	nacl-amd64p32

We may need to adjust the build.golang.org UI after to avoid
including unhelpful columns, but this is a first step to get
nacl builders to run on release branches again.

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

Change-Id: Iaf2b93aedd5f44b48b9a63b57f12549fe50b1637
Reviewed-on: https://go-review.googlesource.com/c/build/+/199800
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/app/appengine/ui.go b/app/appengine/ui.go
index 8f86be6..3128912 100644
--- a/app/appengine/ui.go
+++ b/app/appengine/ui.go
@@ -93,9 +93,9 @@
 			logErr(w, r, err)
 			return
 		}
-		builders := commitBuilders(commits)
-
 		branches := listBranches(c)
+		releaseBranches := supportedReleaseBranches(branches)
+		builders := commitBuilders(commits, releaseBranches)
 
 		var tagState []*TagState
 		// Only show sub-repo state on first page of normal repo view.
@@ -112,7 +112,7 @@
 				return
 			}
 			tagState = []*TagState{s}
-			for _, b := range supportedReleaseBranches(branches) {
+			for _, b := range releaseBranches {
 				s, err := GetTagState(c, "release", b)
 				if err == datastore.ErrNoSuchEntity {
 					continue
@@ -351,9 +351,9 @@
 	return out, err
 }
 
-// commitBuilders returns the names of the builders that provided
+// commitBuilders returns the names of active builders that provided
 // Results for the provided commits.
-func commitBuilders(commits []*Commit) []string {
+func commitBuilders(commits []*Commit, releaseBranches []string) []string {
 	builders := make(map[string]bool)
 	for _, commit := range commits {
 		for _, r := range commit.Results() {
@@ -364,7 +364,7 @@
 	// We want to see columns even if there are no results so we
 	// can identify missing builders. (Issue 19930)
 	for name, bc := range dashboard.Builders {
-		if !bc.BuildsRepoPostSubmit("go", "master", "master") {
+		if !activePostSubmitBuilder(bc, releaseBranches) {
 			continue
 		}
 		builders[name] = true
@@ -374,6 +374,23 @@
 	return k
 }
 
+// activePostSubmitBuilder reports whether the builder bc
+// is considered to be "active", meaning it's configured
+// to test the Go repository on master branch or at least
+// one of the supported release branches.
+func activePostSubmitBuilder(bc *dashboard.BuildConfig, releaseBranches []string) bool {
+	if bc.BuildsRepoPostSubmit("go", "master", "master") {
+		return true
+	}
+	for _, rb := range releaseBranches {
+		if bc.BuildsRepoPostSubmit("go", rb, rb) {
+			return true
+		}
+	}
+	// TODO(golang.org/issue/34744): This doesn't catch x-repo-only builders yet; adjust further as needed.
+	return false
+}
+
 func keys(m map[string]bool) (s []string) {
 	s = make([]string, 0, len(m))
 	for k := range m {