cmd/go: use Bitbucket v2 REST API when determining VCS

The existing implementation uses v1.0 of Bitbucket's REST API. The newer
version 2.0 of Bitbucket's REST API provides the same information but
with support for partial responses allowing the client to request only
the response fields that are relevant to their usage of the API
resulting in a much smaller payload size.

The partial response functionality in the Bitbucket API is documented here:
https://developer.atlassian.com/bitbucket/api/2/reference/meta/partial-response

The v2.0 of the Bitbucket repositories API is documented here:
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D#get

Fixes #18919

Change-Id: I319947d5c51adc241cfe3a2228a667cc43fb1f56
Reviewed-on: https://go-review.googlesource.com/36219
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Mark Adams 2017-02-03 08:46:25 -06:00 committed by Russ Cox
parent a896869a49
commit 275e1fdb20
1 changed files with 1 additions and 1 deletions

View File

@ -948,7 +948,7 @@ func bitbucketVCS(match map[string]string) error {
var resp struct {
SCM string `json:"scm"`
}
url := expand(match, "https://api.bitbucket.org/1.0/repositories/{bitname}")
url := expand(match, "https://api.bitbucket.org/2.0/repositories/{bitname}?fields=scm")
data, err := web.Get(url)
if err != nil {
if httpErr, ok := err.(*web.HTTPError); ok && httpErr.StatusCode == 403 {