IgnoreMod,
[]metaImport{{"chitin.io/chitin", "git", "https://github.com/chitin-io/chitin"}},
},
+ {
+ `<meta name="go-import" content="myitcv.io git https://github.com/myitcv/x">
+ <meta name="go-import" content="myitcv.io/blah2 mod https://raw.githubusercontent.com/myitcv/pubx/master">
+ `,
+ IgnoreMod,
+ []metaImport{{"myitcv.io", "git", "https://github.com/myitcv/x"}},
+ },
+ {
+ `<meta name="go-import" content="myitcv.io git https://github.com/myitcv/x">
+ <meta name="go-import" content="myitcv.io/blah2 mod https://raw.githubusercontent.com/myitcv/pubx/master">
+ `,
+ PreferMod,
+ []metaImport{
+ {"myitcv.io/blah2", "mod", "https://raw.githubusercontent.com/myitcv/pubx/master"},
+ {"myitcv.io", "git", "https://github.com/myitcv/x"},
+ },
+ },
}
func TestParseMetaGoImports(t *testing.T) {
continue
}
- if match != -1 {
+ if match >= 0 {
+ if imports[match].VCS == "mod" && im.VCS != "mod" {
+ // All the mod entries precede all the non-mod entries.
+ // We have a mod entry and don't care about the rest,
+ // matching or not.
+ break
+ }
return metaImport{}, fmt.Errorf("multiple meta tags match import path %q", importPath)
}
match = i
path: "different.example.com/user/foo",
err: errors.New("meta tags do not match import path"),
},
+ {
+ imports: []metaImport{
+ {Prefix: "myitcv.io/blah2", VCS: "mod", RepoRoot: "https://raw.githubusercontent.com/myitcv/pubx/master"},
+ {Prefix: "myitcv.io", VCS: "git", RepoRoot: "https://github.com/myitcv/x"},
+ },
+ path: "myitcv.io/blah2/foo",
+ mi: metaImport{Prefix: "myitcv.io/blah2", VCS: "mod", RepoRoot: "https://raw.githubusercontent.com/myitcv/pubx/master"},
+ },
+ {
+ imports: []metaImport{
+ {Prefix: "myitcv.io/blah2", VCS: "mod", RepoRoot: "https://raw.githubusercontent.com/myitcv/pubx/master"},
+ {Prefix: "myitcv.io", VCS: "git", RepoRoot: "https://github.com/myitcv/x"},
+ },
+ path: "myitcv.io/other",
+ mi: metaImport{Prefix: "myitcv.io", VCS: "git", RepoRoot: "https://github.com/myitcv/x"},
+ },
}
for _, test := range tests {