1
0
mirror of https://github.com/golang/go synced 2024-11-18 10:14:45 -07:00

cmd/go: support git.apache.org Git repos

This change fixes resolution of secure (https) repo URL for
git.apache.org Git repositories.

E.g. the correct repo URL for git.apache.org/thrift.git/lib/go/thrift is
https://git.apache.org/thrift.git, not https://git.apache.org/thrift

Fixes #10797

Change-Id: I67d5312ad8620eb780e42c2e002c8f286f60645a
Reviewed-on: https://go-review.googlesource.com/10092
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Konstantin Shaposhnikov 2015-05-15 00:53:10 +08:00 committed by Russ Cox
parent f35bc3ee87
commit 428ed1e3d9
2 changed files with 32 additions and 0 deletions

View File

@ -882,6 +882,14 @@ var vcsPaths = []*vcsPath{
check: noVCSSuffix, check: noVCSSuffix,
}, },
// Git at Apache
{
prefix: "git.apache.org",
re: `^(?P<root>git.apache.org/[a-z0-9_.\-]+\.git)(/[A-Za-z0-9_.\-]+)*$`,
vcs: "git",
repo: "https://{root}",
},
// General syntax for any server. // General syntax for any server.
{ {
re: `^(?P<root>(?P<repo>([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?/[A-Za-z0-9_.\-/]*?)\.(?P<vcs>bzr|git|hg|svn))(/[A-Za-z0-9_.\-]+)*$`, re: `^(?P<root>(?P<repo>([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?/[A-Za-z0-9_.\-/]*?)\.(?P<vcs>bzr|git|hg|svn))(/[A-Za-z0-9_.\-]+)*$`,

View File

@ -96,6 +96,30 @@ func TestRepoRootForImportPath(t *testing.T) {
"hub.jazz.net/git/USER/pkgname", "hub.jazz.net/git/USER/pkgname",
nil, nil,
}, },
// Spaces are not valid in package name
{
"git.apache.org/package name/path/to/lib",
nil,
},
// Should have ".git" suffix
{
"git.apache.org/package-name/path/to/lib",
nil,
},
{
"git.apache.org/package-name.git",
&repoRoot{
vcs: vcsGit,
repo: "https://git.apache.org/package-name.git",
},
},
{
"git.apache.org/package-name_2.x.git/path/to/lib",
&repoRoot{
vcs: vcsGit,
repo: "https://git.apache.org/package-name_2.x.git",
},
},
} }
for _, test := range tests { for _, test := range tests {