aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Niemeyer <gustavo@niemeyer.net>2012-01-27 00:58:24 -0200
committerGustavo Niemeyer <gustavo@niemeyer.net>2012-01-27 00:58:24 -0200
commitcdbed823bde062cf72f62437261ee9c84007269c (patch)
treebc06275940d6cdd23fe9283e75d6e6fe17071c60
parent2332439b1b02789f5cfeceb78458eb34981e28c8 (diff)
downloadgo-cdbed823bde062cf72f62437261ee9c84007269c.tar.gz
go-cdbed823bde062cf72f62437261ee9c84007269c.zip
cmd/go: solve ambiguity of get lp.net/project/foo
This solves the ambiguity for "lp.net/project/foo". In these URLs, "foo" could be a series name registered in Launchpad with its own branch, and it could also be the name of a directory within the main project branch one level up. Solve it by testing if the series branch exists in Launchpad and if it doesn't moving the root one level up. R=rsc CC=golang-dev https://golang.org/cl/5577058
-rw-r--r--src/cmd/go/vcs.go28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/cmd/go/vcs.go b/src/cmd/go/vcs.go
index 074d63bd40..da35048d53 100644
--- a/src/cmd/go/vcs.go
+++ b/src/cmd/go/vcs.go
@@ -93,8 +93,11 @@ var vcsBzr = &vcsCmd{
name: "Bazaar",
cmd: "bzr",
- createCmd: "branch {repo} {dir}",
- downloadCmd: "pull --overwrite", // TODO: REALLY?
+ createCmd: "branch {repo} {dir}",
+
+ // Without --overwrite bzr will not pull tags that changed.
+ // Replace by --overwrite-tags after http://pad.lv/681792 goes in.
+ downloadCmd: "pull --overwrite",
tagCmd: []tagCmd{{"tags", `^(\S+)`}},
tagDefault: "revno:-1",
@@ -198,7 +201,7 @@ func (v *vcsCmd) tagSync(dir, tag string) error {
return v.run(dir, v.tagSyncCmd, "tag", tag)
}
-// A vcsPath is describes how to convert an import path into a
+// A vcsPath describes how to convert an import path into a
// version control system and repository name.
type vcsPath struct {
prefix string // prefix this description applies to
@@ -302,9 +305,10 @@ var vcsPaths = []*vcsPath{
// Launchpad
{
prefix: "launchpad.net/",
- re: `^(?P<root>launchpad\.net/([A-Za-z0-9_.\-]+(/[A-Za-z0-9_.\-]+)?|~[A-Za-z0-9_.\-]+/(\+junk|[A-Za-z0-9_.\-]+)/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`,
+ re: `^(?P<root>launchpad\.net/((?P<project>[A-Za-z0-9_.\-]+)(?P<series>/[A-Za-z0-9_.\-]+)?|~[A-Za-z0-9_.\-]+/(\+junk|[A-Za-z0-9_.\-]+)/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`,
vcs: "bzr",
repo: "https://{root}",
+ check: launchpadVCS,
},
// General syntax for any server.
@@ -403,3 +407,19 @@ func bitbucketVCS(match map[string]string) error {
return fmt.Errorf("unable to detect version control system for bitbucket.org/ path")
}
+
+// launchpadVCS solves the ambiguity for "lp.net/project/foo". In this case,
+// "foo" could be a series name registered in Launchpad with its own branch,
+// and it could also be the name of a directory within the main project
+// branch one level up.
+func launchpadVCS(match map[string]string) error {
+ if match["project"] == "" || match["series"] == "" {
+ return nil
+ }
+ _, err := httpGET(expand(match, "https://code.launchpad.net/{project}{series}/.bzr/branch-format"))
+ if err != nil {
+ match["root"] = expand(match, "launchpad.net/{project}")
+ match["repo"] = expand(match, "https://{root}")
+ }
+ return nil
+}