mirror of https://github.com/golang/go.git
[release-branch.go1.16] cmd/go: remove mercurial from bitbucket vcs options
Mercurial was deprecated as of July 1, 2020 as per https://bitbucket.org/blog/sunsetting-mercurial-support-in-bitbucket
Fixes #50811.
Updates #50810.
Change-Id: I0d40f84aaa393905cae7c4bed8919b15de9a5f6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/371720
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Bryan Mills <bcmills@google.com>
(cherry picked from commit 5b1b80beb1)
Reviewed-on: https://go-review.googlesource.com/c/go/+/380998
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
This commit is contained in:
parent
355915ba91
commit
0a15110f08
|
|
@ -5,7 +5,6 @@
|
||||||
package vcs
|
package vcs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
exec "internal/execabs"
|
exec "internal/execabs"
|
||||||
|
|
@ -1189,8 +1188,9 @@ var vcsPaths = []*vcsPath{
|
||||||
{
|
{
|
||||||
pathPrefix: "bitbucket.org",
|
pathPrefix: "bitbucket.org",
|
||||||
regexp: lazyregexp.New(`^(?P<root>bitbucket\.org/(?P<bitname>[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`),
|
regexp: lazyregexp.New(`^(?P<root>bitbucket\.org/(?P<bitname>[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`),
|
||||||
|
vcs: "git",
|
||||||
repo: "https://{root}",
|
repo: "https://{root}",
|
||||||
check: bitbucketVCS,
|
check: noVCSSuffix,
|
||||||
},
|
},
|
||||||
|
|
||||||
// IBM DevOps Services (JazzHub)
|
// IBM DevOps Services (JazzHub)
|
||||||
|
|
@ -1262,56 +1262,6 @@ func noVCSSuffix(match map[string]string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// bitbucketVCS determines the version control system for a
|
|
||||||
// Bitbucket repository, by using the Bitbucket API.
|
|
||||||
func bitbucketVCS(match map[string]string) error {
|
|
||||||
if err := noVCSSuffix(match); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var resp struct {
|
|
||||||
SCM string `json:"scm"`
|
|
||||||
}
|
|
||||||
url := &urlpkg.URL{
|
|
||||||
Scheme: "https",
|
|
||||||
Host: "api.bitbucket.org",
|
|
||||||
Path: expand(match, "/2.0/repositories/{bitname}"),
|
|
||||||
RawQuery: "fields=scm",
|
|
||||||
}
|
|
||||||
data, err := web.GetBytes(url)
|
|
||||||
if err != nil {
|
|
||||||
if httpErr, ok := err.(*web.HTTPError); ok && httpErr.StatusCode == 403 {
|
|
||||||
// this may be a private repository. If so, attempt to determine which
|
|
||||||
// VCS it uses. See issue 5375.
|
|
||||||
root := match["root"]
|
|
||||||
for _, vcs := range []string{"git", "hg"} {
|
|
||||||
if vcsByCmd(vcs).Ping("https", root) == nil {
|
|
||||||
resp.SCM = vcs
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if resp.SCM == "" {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if err := json.Unmarshal(data, &resp); err != nil {
|
|
||||||
return fmt.Errorf("decoding %s: %v", url, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if vcsByCmd(resp.SCM) != nil {
|
|
||||||
match["vcs"] = resp.SCM
|
|
||||||
if resp.SCM == "git" {
|
|
||||||
match["repo"] += ".git"
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
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,
|
// 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,
|
// "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
|
// and it could also be the name of a directory within the main project
|
||||||
|
|
|
||||||
|
|
@ -183,6 +183,13 @@ func TestRepoRootForImportPath(t *testing.T) {
|
||||||
"chiselapp.com/user/kyle/fossilgg",
|
"chiselapp.com/user/kyle/fossilgg",
|
||||||
nil,
|
nil,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"bitbucket.org/workspace/pkgname",
|
||||||
|
&RepoRoot{
|
||||||
|
VCS: vcsGit,
|
||||||
|
Repo: "https://bitbucket.org/workspace/pkgname",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue