diff --git a/src/cmd/go/vcs.go b/src/cmd/go/vcs.go index 64cbf45a74..8871f77371 100644 --- a/src/cmd/go/vcs.go +++ b/src/cmd/go/vcs.go @@ -882,6 +882,14 @@ var vcsPaths = []*vcsPath{ check: noVCSSuffix, }, + // Git at Apache + { + prefix: "git.apache.org", + re: `^(?Pgit.apache.org/[a-z0-9_.\-]+\.git)(/[A-Za-z0-9_.\-]+)*$`, + vcs: "git", + repo: "https://{root}", + }, + // General syntax for any server. { re: `^(?P(?P([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?/[A-Za-z0-9_.\-/]*?)\.(?Pbzr|git|hg|svn))(/[A-Za-z0-9_.\-]+)*$`, diff --git a/src/cmd/go/vcs_test.go b/src/cmd/go/vcs_test.go index 44f7ea8418..f5d5e4f4f0 100644 --- a/src/cmd/go/vcs_test.go +++ b/src/cmd/go/vcs_test.go @@ -96,6 +96,30 @@ func TestRepoRootForImportPath(t *testing.T) { "hub.jazz.net/git/USER/pkgname", 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 {