diff options
author | Chris McGee <sirnewton_01@yahoo.ca> | 2014-07-15 11:27:04 +1000 |
---|---|---|
committer | Chris McGee <sirnewton_01@yahoo.ca> | 2014-07-15 11:27:04 +1000 |
commit | 5ec6f6a7c5835132a40a21ab658de257b4844b6d (patch) | |
tree | b69d2b285deb083034f33e5e61a86180c1fb950e /src | |
parent | 04a99cd488458d8832be384bfd1507447cf309d2 (diff) | |
download | go-5ec6f6a7c5835132a40a21ab658de257b4844b6d.tar.gz |
go get: Support for IBM DevOps Services (hub.jazz.net) git repos
LGTM=adg
R=golang-codereviews, adg, minux
CC=golang-codereviews
https://codereview.appspot.com/106740044
Committer: Andrew Gerrand <adg@golang.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/go/doc.go | 5 | ||||
-rw-r--r-- | src/cmd/go/help.go | 5 | ||||
-rw-r--r-- | src/cmd/go/vcs.go | 9 | ||||
-rw-r--r-- | src/cmd/go/vcs_test.go | 116 |
4 files changed, 135 insertions, 0 deletions
diff --git a/src/cmd/go/doc.go b/src/cmd/go/doc.go index 52737f9f8..c85d1c323 100644 --- a/src/cmd/go/doc.go +++ b/src/cmd/go/doc.go @@ -681,6 +681,11 @@ A few common code hosting sites have special syntax: import "launchpad.net/~user/project/branch" import "launchpad.net/~user/project/branch/sub/directory" + IBM DevOps Services (Git) + + import "hub.jazz.net/git/user/project" + import "hub.jazz.net/git/user/project/sub/directory" + For code hosted on other servers, import paths may either be qualified with the version control type, or the go tool can dynamically fetch the import path over https/http and discover where the code resides diff --git a/src/cmd/go/help.go b/src/cmd/go/help.go index 40da7e1f5..d6651d179 100644 --- a/src/cmd/go/help.go +++ b/src/cmd/go/help.go @@ -154,6 +154,11 @@ A few common code hosting sites have special syntax: import "launchpad.net/~user/project/branch" import "launchpad.net/~user/project/branch/sub/directory" + IBM DevOps Services (Git) + + import "hub.jazz.net/git/user/project" + import "hub.jazz.net/git/user/project/sub/directory" + For code hosted on other servers, import paths may either be qualified with the version control type, or the go tool can dynamically fetch the import path over https/http and discover where the code resides diff --git a/src/cmd/go/vcs.go b/src/cmd/go/vcs.go index 8f0bae0b7..d07948e64 100644 --- a/src/cmd/go/vcs.go +++ b/src/cmd/go/vcs.go @@ -613,6 +613,15 @@ var vcsPaths = []*vcsPath{ check: launchpadVCS, }, + // IBM DevOps Services (JazzHub) + { + prefix: "hub.jazz.net/git", + re: `^(?P<root>hub.jazz.net/git/[a-z0-9]+/[A-Za-z0-9_.\-]+)(/[A-Za-z0-9_.\-]+)*$`, + vcs: "git", + repo: "https://{root}", + check: noVCSSuffix, + }, + // 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_.\-]+)*$`, diff --git a/src/cmd/go/vcs_test.go b/src/cmd/go/vcs_test.go new file mode 100644 index 000000000..820e47812 --- /dev/null +++ b/src/cmd/go/vcs_test.go @@ -0,0 +1,116 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "testing" +) + +// Test that RepoRootForImportPath creates the correct RepoRoot for a given importPath. +// TODO(cmang): Add tests for SVN and BZR. +func TestRepoRootForImportPath(t *testing.T) { + tests := []struct { + path string + want *repoRoot + }{ + { + "code.google.com/p/go", + &repoRoot{ + vcs: vcsHg, + repo: "https://code.google.com/p/go", + }, + }, + /*{ + "code.google.com/r/go", + &repoRoot{ + vcs: vcsHg, + repo: "https://code.google.com/r/go", + }, + },*/ + { + "github.com/golang/groupcache", + &repoRoot{ + vcs: vcsGit, + repo: "https://github.com/golang/groupcache", + }, + }, + // IBM DevOps Services tests + { + "hub.jazz.net/git/user1/pkgname", + &repoRoot{ + vcs: vcsGit, + repo: "https://hub.jazz.net/git/user1/pkgname", + }, + }, + { + "hub.jazz.net/git/user1/pkgname/submodule/submodule/submodule", + &repoRoot{ + vcs: vcsGit, + repo: "https://hub.jazz.net/git/user1/pkgname", + }, + }, + { + "hub.jazz.net", + nil, + }, + { + "hub2.jazz.net", + nil, + }, + { + "hub.jazz.net/someotherprefix", + nil, + }, + { + "hub.jazz.net/someotherprefix/user1/pkgname", + nil, + }, + // Spaces are not valid in user names or package names + { + "hub.jazz.net/git/User 1/pkgname", + nil, + }, + { + "hub.jazz.net/git/user1/pkg name", + nil, + }, + // Dots are not valid in user names + { + "hub.jazz.net/git/user.1/pkgname", + nil, + }, + { + "hub.jazz.net/git/user/pkg.name", + &repoRoot{ + vcs: vcsGit, + repo: "https://hub.jazz.net/git/user/pkg.name", + }, + }, + // User names cannot have uppercase letters + { + "hub.jazz.net/git/USER/pkgname", + nil, + }, + } + + for _, test := range tests { + got, err := repoRootForImportPath(test.path) + want := test.want + + if want == nil { + if err == nil { + t.Errorf("RepoRootForImport(%q): Error expected but not received") + } + continue + } + if err != nil { + t.Errorf("RepoRootForImport(%q): %v", test.path, err) + continue + } + if got.vcs.name != want.vcs.name || got.repo != want.repo { + t.Errorf("RepoRootForImport(%q) = VCS(%s) Repo(%s), want VCS(%s) Repo(%s)", test.path, got.vcs, got.repo, want.vcs, want.repo) + } + } +} |