зеркало из https://github.com/golang/pkgsite.git
internal/source: support git.apache.org
git.apache.org repos are hosted on GitHub. The final ".git" in the module path throws off the meta-tag matcher, so handle it specially. Change-Id: I57a8da4d4a000f0acd72945b6efa4439579e6518 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/572877 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
This commit is contained in:
Родитель
cd16968f5a
Коммит
2696ea77a3
|
@ -161,6 +161,13 @@ func matchStatic(moduleOrRepoPath string) (repo, relativeModulePath string, _ ur
|
|||
break
|
||||
}
|
||||
}
|
||||
// Special case: git.apache.org has a go-import tag that points to
|
||||
// github.com/apache, but it's not quite right (the repo prefix is
|
||||
// missing a ".git"), so handle it here.
|
||||
const apacheDomain = "git.apache.org/"
|
||||
if strings.HasPrefix(repo, apacheDomain) {
|
||||
repo = strings.Replace(repo, apacheDomain, "github.com/apache/", 1)
|
||||
}
|
||||
relativeModulePath = strings.TrimPrefix(moduleOrRepoPath, matches[0])
|
||||
relativeModulePath = strings.TrimPrefix(relativeModulePath, "/")
|
||||
return repo, relativeModulePath, pat.templates, nil
|
||||
|
@ -316,13 +323,17 @@ var patterns = []struct {
|
|||
// a ".git" repo suffix in an import path. If matching a repo URL from a meta tag,
|
||||
// there is no ".git".
|
||||
{
|
||||
regexp.MustCompile(`^(?P<repo>[^.]+\.googlesource.com/[^.]+)(\.git|$)`),
|
||||
regexp.MustCompile(`^(?P<repo>[^.]+\.googlesource\.com/[^.]+)(\.git|$)`),
|
||||
urlTemplates{
|
||||
directory: "{repo}/+/{commit}/{dir}",
|
||||
file: "{repo}/+/{commit}/{file}",
|
||||
line: "{repo}/+/{commit}/{file}#{line}",
|
||||
},
|
||||
},
|
||||
{
|
||||
regexp.MustCompile(`^(?P<repo>git\.apache\.org/[^.]+)(\.git|$)`),
|
||||
githubURLTemplates,
|
||||
},
|
||||
// General syntax for the go command. We can extract the repo and directory, but
|
||||
// we don't know the URL templates.
|
||||
// Must be last in this list.
|
||||
|
|
|
@ -111,6 +111,15 @@ func TestModuleInfo(t *testing.T) {
|
|||
"https://go.googlesource.com/image/+/69e4b8554b2a/math/fixed/fixed.go",
|
||||
"https://go.googlesource.com/image/+/69e4b8554b2a/math/fixed/fixed.go#1",
|
||||
},
|
||||
{
|
||||
"git.apache.org",
|
||||
"git.apache.org/thrift.git", "v0.12.0", "lib/go/thrift/client.go",
|
||||
|
||||
"https://github.com/apache/thrift",
|
||||
"https://github.com/apache/thrift/tree/v0.12.0",
|
||||
"https://github.com/apache/thrift/blob/v0.12.0/lib/go/thrift/client.go",
|
||||
"https://github.com/apache/thrift/blob/v0.12.0/lib/go/thrift/client.go#L1",
|
||||
},
|
||||
{
|
||||
"vanity for github",
|
||||
"cloud.google.com/go/spanner", "v1.0.0", "doc.go",
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче