File fix-tag-already-exists.patch of Package go1.21
Index: go-go1.21.13/src/cmd/go/internal/modfetch/codehost/git_test.go
===================================================================
--- go-go1.21.13.orig/src/cmd/go/internal/modfetch/codehost/git_test.go
+++ go-go1.21.13/src/cmd/go/internal/modfetch/codehost/git_test.go
@@ -620,172 +620,6 @@ func TestReadZip(t *testing.T) {
}
}
-var hgmap = map[string]string{
- "HEAD": "41964ddce1180313bdc01d0a39a2813344d6261d", // not tip due to bad hgrepo1 conversion
- "9d02800338b8a55be062c838d1f02e0c5780b9eb": "8f49ee7a6ddcdec6f0112d9dca48d4a2e4c3c09e",
- "76a00fb249b7f93091bc2c89a789dab1fc1bc26f": "88fde824ec8b41a76baa16b7e84212cee9f3edd0",
- "ede458df7cd0fdca520df19a33158086a8a68e81": "41964ddce1180313bdc01d0a39a2813344d6261d",
- "97f6aa59c81c623494825b43d39e445566e429a4": "c0cbbfb24c7c3c50c35c7b88e7db777da4ff625d",
-}
-
-func TestStat(t *testing.T) {
- t.Parallel()
-
- type statTest struct {
- repo string
- rev string
- err string
- info *RevInfo
- }
- runTest := func(tt statTest) func(*testing.T) {
- return func(t *testing.T) {
- t.Parallel()
- ctx := testContext(t)
-
- r, err := testRepo(ctx, t, tt.repo)
- if err != nil {
- t.Fatal(err)
- }
- info, err := r.Stat(ctx, tt.rev)
- if err != nil {
- if tt.err == "" {
- t.Fatalf("Stat: unexpected error %v", err)
- }
- if !strings.Contains(err.Error(), tt.err) {
- t.Fatalf("Stat: wrong error %q, want %q", err, tt.err)
- }
- if info != nil && info.Origin == nil {
- t.Errorf("Stat: non-nil info with nil Origin with error %q", err)
- }
- return
- }
- info.Origin = nil // TestLatest and ../../../testdata/script/reuse_git.txt test Origin well enough
- if !reflect.DeepEqual(info, tt.info) {
- if !reflect.DeepEqual(info.Tags, tt.info.Tags) {
- testenv.SkipFlaky(t, 56881)
- }
- t.Errorf("Stat: incorrect info\nhave %+v\nwant %+v", *info, *tt.info)
- }
- }
- }
-
- for _, tt := range []statTest{
- {
- repo: gitrepo1,
- rev: "HEAD",
- info: &RevInfo{
- Name: "ede458df7cd0fdca520df19a33158086a8a68e81",
- Short: "ede458df7cd0",
- Version: "ede458df7cd0fdca520df19a33158086a8a68e81",
- Time: time.Date(2018, 4, 17, 19, 43, 22, 0, time.UTC),
- Tags: []string{"v1.2.3", "v1.2.4-annotated"},
- },
- },
- {
- repo: gitrepo1,
- rev: "v2", // branch
- info: &RevInfo{
- Name: "9d02800338b8a55be062c838d1f02e0c5780b9eb",
- Short: "9d02800338b8",
- Version: "9d02800338b8a55be062c838d1f02e0c5780b9eb",
- Time: time.Date(2018, 4, 17, 20, 00, 32, 0, time.UTC),
- Tags: []string{"v2.0.2"},
- },
- },
- {
- repo: gitrepo1,
- rev: "v2.3.4", // badly-named branch (semver should be a tag)
- info: &RevInfo{
- Name: "76a00fb249b7f93091bc2c89a789dab1fc1bc26f",
- Short: "76a00fb249b7",
- Version: "76a00fb249b7f93091bc2c89a789dab1fc1bc26f",
- Time: time.Date(2018, 4, 17, 19, 45, 48, 0, time.UTC),
- Tags: []string{"v2.0.1", "v2.3"},
- },
- },
- {
- repo: gitrepo1,
- rev: "v2.3", // badly-named tag (we only respect full semver v2.3.0)
- info: &RevInfo{
- Name: "76a00fb249b7f93091bc2c89a789dab1fc1bc26f",
- Short: "76a00fb249b7",
- Version: "v2.3",
- Time: time.Date(2018, 4, 17, 19, 45, 48, 0, time.UTC),
- Tags: []string{"v2.0.1", "v2.3"},
- },
- },
- {
- repo: gitrepo1,
- rev: "v1.2.3", // tag
- info: &RevInfo{
- Name: "ede458df7cd0fdca520df19a33158086a8a68e81",
- Short: "ede458df7cd0",
- Version: "v1.2.3",
- Time: time.Date(2018, 4, 17, 19, 43, 22, 0, time.UTC),
- Tags: []string{"v1.2.3", "v1.2.4-annotated"},
- },
- },
- {
- repo: gitrepo1,
- rev: "ede458df", // hash prefix in refs
- info: &RevInfo{
- Name: "ede458df7cd0fdca520df19a33158086a8a68e81",
- Short: "ede458df7cd0",
- Version: "ede458df7cd0fdca520df19a33158086a8a68e81",
- Time: time.Date(2018, 4, 17, 19, 43, 22, 0, time.UTC),
- Tags: []string{"v1.2.3", "v1.2.4-annotated"},
- },
- },
- {
- repo: gitrepo1,
- rev: "97f6aa59", // hash prefix not in refs
- info: &RevInfo{
- Name: "97f6aa59c81c623494825b43d39e445566e429a4",
- Short: "97f6aa59c81c",
- Version: "97f6aa59c81c623494825b43d39e445566e429a4",
- Time: time.Date(2018, 4, 17, 20, 0, 19, 0, time.UTC),
- },
- },
- {
- repo: gitrepo1,
- rev: "v1.2.4-annotated", // annotated tag uses unwrapped commit hash
- info: &RevInfo{
- Name: "ede458df7cd0fdca520df19a33158086a8a68e81",
- Short: "ede458df7cd0",
- Version: "v1.2.4-annotated",
- Time: time.Date(2018, 4, 17, 19, 43, 22, 0, time.UTC),
- Tags: []string{"v1.2.3", "v1.2.4-annotated"},
- },
- },
- {
- repo: gitrepo1,
- rev: "aaaaaaaaab",
- err: "unknown revision",
- },
- } {
- t.Run(path.Base(tt.repo)+"/"+tt.rev, runTest(tt))
- if tt.repo == gitrepo1 {
- for _, tt.repo = range altRepos() {
- old := tt
- var m map[string]string
- if tt.repo == hgrepo1 {
- m = hgmap
- }
- if tt.info != nil {
- info := *tt.info
- tt.info = &info
- tt.info.Name = remap(tt.info.Name, m)
- tt.info.Version = remap(tt.info.Version, m)
- tt.info.Short = remap(tt.info.Short, m)
- }
- tt.rev = remap(tt.rev, m)
- t.Run(path.Base(tt.repo)+"/"+tt.rev, runTest(tt))
- tt = old
- }
- }
- }
-}
-
func remap(name string, m map[string]string) string {
if m[name] != "" {
return m[name]