internal/task: drop tagx:compat magic comment in tagging workflow

It's no longer used, and not expected to be needed in the future.
As of Go 1.21, the go directive is a more direct way of stating the
minimum Go version to stay compatible with.

For golang/go#48523.

Change-Id: I3932a103982a6843194195c99304bf265217b8d1
Reviewed-on: https://go-review.googlesource.com/c/build/+/609397
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/internal/task/tagx.go b/internal/task/tagx.go
index 54ffe5e..9da932d 100644
--- a/internal/task/tagx.go
+++ b/internal/task/tagx.go
@@ -69,7 +69,6 @@
 	Name         string    // Gerrit project name, e.g., "tools".
 	ModPath      string    // Module path, e.g., "golang.org/x/tools".
 	Deps         []*TagDep // Dependency modules.
-	Compat       string    // The Go version to pass to go mod tidy -compat for this repository.
 	HasToolchain bool      // Whether the go.mod file has a toolchain directive when the workflow started.
 	StartVersion string    // The version of the module when the workflow started. Empty string means repo hasn't begun release version tagging yet.
 	NewerVersion string    // The version of the module that will be tagged, or the empty string when the repo is being updated only and not tagged.
@@ -195,14 +194,6 @@
 		StartVersion: currentTag,
 	}
 
-	compatRe := regexp.MustCompile(`tagx:compat\s+([\d.]+)`)
-	if mf.Go != nil {
-		for _, c := range mf.Go.Syntax.Comments.Suffix {
-			if matches := compatRe.FindStringSubmatch(c.Token); matches != nil {
-				result.Compat = matches[1]
-			}
-		}
-	}
 	for _, req := range mf.Require {
 		if !isXRoot(req.Mod.Path) {
 			continue
@@ -415,17 +406,13 @@
 	}
 	var outputs []string
 	for _, dir := range dirs {
-		compat := ""
-		if repo.Compat != "" {
-			compat = "-compat " + repo.Compat
-		}
 		dropToolchain := ""
 		if !repo.HasToolchain {
 			// Don't introduce a toolchain directive if it wasn't already there.
 			// TODO(go.dev/issue/68873): Read the nested module's go.mod. For now, re-use decision from the top-level module.
 			dropToolchain = " && go get toolchain@none"
 		}
-		script.WriteString(fmt.Sprintf("(cd %v && touch go.sum && go mod tidy %s%s)\n", dir, compat, dropToolchain))
+		script.WriteString(fmt.Sprintf("(cd %v && touch go.sum && go mod tidy%s)\n", dir, dropToolchain))
 		outputs = append(outputs, dir+"/go.mod", dir+"/go.sum")
 	}
 	build, err := x.CloudBuild.RunScript(ctx, script.String(), repo.Name, outputs)
diff --git a/internal/task/tagx_test.go b/internal/task/tagx_test.go
index 3817910..d12304d 100644
--- a/internal/task/tagx_test.go
+++ b/internal/task/tagx_test.go
@@ -307,7 +307,7 @@
 	mod.Tag("v1.0.0", mod1)
 	tools := NewFakeRepo(t, "tools")
 	tools1 := tools.Commit(map[string]string{
-		"go.mod":       "module golang.org/x/tools\nrequire golang.org/x/mod v1.0.0\ngo 1.18 // tagx:compat 1.16\nrequire golang.org/x/sys v0.1.0\nrequire golang.org/x/build v0.0.0\n",
+		"go.mod":       "module golang.org/x/tools\nrequire golang.org/x/mod v1.0.0\ngo 1.18\nrequire golang.org/x/sys v0.1.0\nrequire golang.org/x/build v0.0.0\n",
 		"go.sum":       "\n",
 		"gopls/go.mod": "module golang.org/x/tools/gopls\nrequire golang.org/x/mod v1.0.0\n",
 		"gopls/go.sum": "\n",
@@ -368,8 +368,8 @@
 	if err != nil {
 		t.Fatal(err)
 	}
-	if !strings.Contains(string(goplsMod), "tidied!") || !strings.Contains(string(goplsMod), "1.16") || strings.Contains(string(goplsMod), "upgraded") {
-		t.Errorf("gopls go.mod should be tidied with -compat 1.16, but not upgraded:\n%s", goplsMod)
+	if !strings.Contains(string(goplsMod), "tidied!") || strings.Contains(string(goplsMod), "upgraded") {
+		t.Errorf("gopls go.mod should be tidied and not upgraded:\n%s", goplsMod)
 	}
 
 	tags, err = deps.gerrit.ListTags(ctx, "build")