gerrit: add ability to pass QueryChangesOpt to GetChangeDetail

The existing implementation of GetChangeDetail does not allow for
an optional QueryChangesOpt. QueryChangesOpt adds the ability to
pass options such as CURRENT_FILES and CURRENT_REVISION in order
to receive a more detailed ChangeInfo struct.

Change-Id: I7925e75821538b2720fff7d62c8404ed97e18791
Reviewed-on: https://go-review.googlesource.com/34922
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
shawnps 2017-01-07 05:58:43 -08:00 коммит произвёл Brad Fitzpatrick
Родитель 6809b41628
Коммит 2610191dbd
1 изменённых файлов: 12 добавлений и 2 удалений

Просмотреть файл

@ -345,9 +345,19 @@ func (c *Client) QueryChanges(q string, opts ...QueryChangesOpt) ([]*ChangeInfo,
// GetChangeDetail retrieves a change with labels, detailed labels, detailed
// accounts, and messages.
// For the API call, see https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-change-detail
func (c *Client) GetChangeDetail(changeID string) (*ChangeInfo, error) {
func (c *Client) GetChangeDetail(changeID string, opts ...QueryChangesOpt) (*ChangeInfo, error) {
var opt QueryChangesOpt
switch len(opts) {
case 0:
case 1:
opt = opts[0]
default:
return nil, errors.New("only 1 option struct supported")
}
var change ChangeInfo
err := c.do(&change, "GET", "/changes/"+changeID+"/detail")
err := c.do(&change, "GET", "/changes/"+changeID+"/detail", urlValues{
"o": opt.Fields,
})
if err != nil {
return nil, err
}