Skip to content

Commit aeec1e9

Browse files
committed
add AbandonChange
1 parent a2e6113 commit aeec1e9

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ first. For more complete details see
77

88
## Versions
99

10+
### 0.5.1
11+
12+
* Added the `AbandonChange` function.
13+
1014
### 0.5.0
1115

1216
**WARNING**: This release includes breaking changes.

changes.go

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,17 @@ type GitPersonInfo struct {
3131
TZ int `json:"tz"`
3232
}
3333

34+
// NotifyInfo entity contains detailed information about who should be
35+
// notified about an update
36+
type NotifyInfo struct {
37+
Accounts []AccountInfo `json:"accounts"`
38+
}
39+
3440
// AbandonInput entity contains information for abandoning a change.
3541
type AbandonInput struct {
36-
Message string `json:"message,omitempty"`
42+
Message string `json:"message,omitempty"`
43+
Notify string `json:"notify"`
44+
NotifyDetails []NotifyInfo `json:"notify_details"`
3745
}
3846

3947
// ApprovalInfo entity contains information about an approval from a user for a label on a change.
@@ -706,9 +714,29 @@ func (s *ChangesService) SubmitChange(changeID string, input *SubmitInput) (*Cha
706714
return v, resp, err
707715
}
708716

717+
// AbandonChange abandons a change.
718+
//
719+
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#abandon-change
720+
func (s *ChangesService) AbandonChange(changeID string, input *AbandonInput) (*ChangeInfo, *Response, error) {
721+
u := fmt.Sprintf("changes/%s/abandon", changeID)
722+
723+
req, err := s.client.NewRequest("POST", u, input)
724+
if err != nil {
725+
return nil, nil, err
726+
}
727+
728+
v := new(ChangeInfo)
729+
730+
resp, err := s.client.Do(req, v)
731+
if resp.StatusCode == http.StatusConflict {
732+
body, _ := ioutil.ReadAll(resp.Body)
733+
err = errors.New(string(body[:]))
734+
}
735+
return v, resp, err
736+
}
737+
709738
/*
710739
Missing Change Endpoints
711-
Abandon Change
712740
Restore Change
713741
Rebase Change
714742
Revert Change

0 commit comments

Comments
 (0)