internal/task: filter out cmd/internal/metadata

We don't want to include the metadata command in the release. Exclude
it.

For golang/go#50146.

Change-Id: I0e7c8b94afe07ffd8396d7bac1c039c972a1b855
Reviewed-on: https://go-review.googlesource.com/c/build/+/411061
Reviewed-by: Alex Rakoczy <alex@golang.org>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/internal/task/buildrelease.go b/internal/task/buildrelease.go
index 9b0a23c..51cf41f 100644
--- a/internal/task/buildrelease.go
+++ b/internal/task/buildrelease.go
@@ -131,6 +131,9 @@
 	// Users don't need the api checker binary pre-built. It's
 	// used by tests, but all.bash builds it first.
 	`pkg/tool/[^/]+/api.*`,
+	// Users also don't need the metadata command, which is run dynamically
+	// by cmd/dist. As of writing we don't know why it's showing up at all.
+	`pkg/tool/[^/]+/metadata.*`,
 	// Remove pkg/${GOOS}_${GOARCH}/cmd. This saves a bunch of
 	// space, and users don't typically rebuild cmd/compile,
 	// cmd/link, etc. If they want to, they still can, but they'll
diff --git a/internal/task/buildrelease_test.go b/internal/task/buildrelease_test.go
index cf43c8a..dc69ad3 100644
--- a/internal/task/buildrelease_test.go
+++ b/internal/task/buildrelease_test.go
@@ -40,6 +40,7 @@
 		{"bin/go", true},
 		{"pkg/obj/README", false},
 		{"pkg/tool/linux_amd64/api", false},
+		{"pkg/tool/linux_amd64/metadata", false},
 		{"pkg/linux_amd64/cmd/go.a", false},
 		{"pkg/linux_amd64/runtime.a", true},
 		{"bin/go.exe~", false},