Commit 275e1fdb authored by Mark Adams's avatar Mark Adams Committed by Russ Cox

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: default avatarRuss Cox <rsc@golang.org>
parent a896869a
...@@ -948,7 +948,7 @@ func bitbucketVCS(match map[string]string) error { ...@@ -948,7 +948,7 @@ func bitbucketVCS(match map[string]string) error {
var resp struct { var resp struct {
SCM string `json:"scm"` 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) data, err := web.Get(url)
if err != nil { if err != nil {
if httpErr, ok := err.(*web.HTTPError); ok && httpErr.StatusCode == 403 { if httpErr, ok := err.(*web.HTTPError); ok && httpErr.StatusCode == 403 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment