Skip to content

Commit ce6e2a5

Browse files
aethanoljproberts
authored andcommitted
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 golang#50810. Change-Id: I0d40f84aaa393905cae7c4bed8919b15de9a5f6d Reviewed-on: https://go-review.googlesource.com/c/go/+/371720 Trust: Russ Cox <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Trust: Bryan Mills <[email protected]>
1 parent bf77446 commit ce6e2a5

File tree

2 files changed

+9
-52
lines changed

2 files changed

+9
-52
lines changed

src/cmd/go/internal/vcs/vcs.go

+2-52
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package vcs
66

77
import (
88
"bytes"
9-
"encoding/json"
109
"errors"
1110
"fmt"
1211
exec "internal/execabs"
@@ -1437,8 +1436,9 @@ var vcsPaths = []*vcsPath{
14371436
{
14381437
pathPrefix: "bitbucket.org",
14391438
regexp: lazyregexp.New(`^(?P<root>bitbucket\.org/(?P<bitname>[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`),
1439+
vcs: "git",
14401440
repo: "https://{root}",
1441-
check: bitbucketVCS,
1441+
check: noVCSSuffix,
14421442
},
14431443

14441444
// IBM DevOps Services (JazzHub)
@@ -1510,56 +1510,6 @@ func noVCSSuffix(match map[string]string) error {
15101510
return nil
15111511
}
15121512

1513-
// bitbucketVCS determines the version control system for a
1514-
// Bitbucket repository, by using the Bitbucket API.
1515-
func bitbucketVCS(match map[string]string) error {
1516-
if err := noVCSSuffix(match); err != nil {
1517-
return err
1518-
}
1519-
1520-
var resp struct {
1521-
SCM string `json:"scm"`
1522-
}
1523-
url := &urlpkg.URL{
1524-
Scheme: "https",
1525-
Host: "api.bitbucket.org",
1526-
Path: expand(match, "/2.0/repositories/{bitname}"),
1527-
RawQuery: "fields=scm",
1528-
}
1529-
data, err := web.GetBytes(url)
1530-
if err != nil {
1531-
if httpErr, ok := err.(*web.HTTPError); ok && httpErr.StatusCode == 403 {
1532-
// this may be a private repository. If so, attempt to determine which
1533-
// VCS it uses. See issue 5375.
1534-
root := match["root"]
1535-
for _, vcs := range []string{"git", "hg"} {
1536-
if vcsByCmd(vcs).Ping("https", root) == nil {
1537-
resp.SCM = vcs
1538-
break
1539-
}
1540-
}
1541-
}
1542-
1543-
if resp.SCM == "" {
1544-
return err
1545-
}
1546-
} else {
1547-
if err := json.Unmarshal(data, &resp); err != nil {
1548-
return fmt.Errorf("decoding %s: %v", url, err)
1549-
}
1550-
}
1551-
1552-
if vcsByCmd(resp.SCM) != nil {
1553-
match["vcs"] = resp.SCM
1554-
if resp.SCM == "git" {
1555-
match["repo"] += ".git"
1556-
}
1557-
return nil
1558-
}
1559-
1560-
return fmt.Errorf("unable to detect version control system for bitbucket.org/ path")
1561-
}
1562-
15631513
// launchpadVCS solves the ambiguity for "lp.net/project/foo". In this case,
15641514
// "foo" could be a series name registered in Launchpad with its own branch,
15651515
// and it could also be the name of a directory within the main project

src/cmd/go/internal/vcs/vcs_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ func TestRepoRootForImportPath(t *testing.T) {
183183
"chiselapp.com/user/kyle/fossilgg",
184184
nil,
185185
},
186+
{
187+
"bitbucket.org/workspace/pkgname",
188+
&RepoRoot{
189+
VCS: vcsGit,
190+
Repo: "https://bitbucket.org/workspace/pkgname",
191+
},
192+
},
186193
}
187194

188195
for _, test := range tests {

0 commit comments

Comments
 (0)