internal/source: support gitlab module paths

gitlab.com serves source information just like github. Add it to the list
of known patterns.

Change-Id: I0b102d2c56c03a4ec8904f089f09ef6793db9c7f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/562177
Reviewed-by: Julie Qiu <julieqiu@google.com>
This commit is contained in:
Jonathan Amsterdam 2019-09-30 11:14:34 -04:00 коммит произвёл Julie Qiu
Родитель 081e3bd1dd
Коммит 1fa0ab8257
3 изменённых файлов: 1025 добавлений и 668 удалений

Просмотреть файл

@ -214,6 +214,12 @@ var patterns = []struct {
// git.openstack.org has been rebranded.
// chiselapp.com has no Go packages in godoc.org.
// Patterns that are not (yet) part of the go command.
{
regexp.MustCompile(`^(?P<repo>gitlab\.com/[a-z0-9A-Z_.\-]+/[a-z0-9A-Z_.\-]+)`),
githubURLTemplates,
},
// Patterns that match the general go command pattern, where they must have
// a ".git" repo suffix in an import path. If matching a repo URL from a meta tag,
// there is no ".git".

Просмотреть файл

@ -138,6 +138,15 @@ func TestModuleInfo(t *testing.T) {
"https://cue.googlesource.com/cue/+/v0.0.9/cuego/doc.go",
"https://cue.googlesource.com/cue/+/v0.0.9/cuego/doc.go#1",
},
{
"gitlab",
"gitlab.com/akita/akita", "v1.4.1", "event.go",
"https://gitlab.com/akita/akita",
"https://gitlab.com/akita/akita/tree/v1.4.1",
"https://gitlab.com/akita/akita/blob/v1.4.1/event.go",
"https://gitlab.com/akita/akita/blob/v1.4.1/event.go#L1",
},
} {
t.Run(test.desc, func(t *testing.T) {
check := func(msg, got, want string) {

1678
internal/source/testdata/TestModuleInfo.replay поставляемый

Разница между файлами не показана из-за своего большого размера Загрузить разницу