Skip to content

Commit 9fa2048

Browse files
committed
added RevertChange
1 parent 8cd4eeb commit 9fa2048

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ first. For more complete details see
99

1010
### 0.5.1
1111

12-
* Added the `AbandonChange`, `RebaseChange` and `RestoreChange` functions.
12+
* Added the `AbandonChange`, `RebaseChange`, `RestoreChange` and
13+
`RevertChange` functions.
1314

1415
### 0.5.0
1516

changes.go

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -786,8 +786,27 @@ func (s *ChangesService) RestoreChange(changeID string, input *RestoreInput) (*C
786786
return v, resp, err
787787
}
788788

789+
// RevertChange reverts a change.
790+
//
791+
// The request body does not need to include a RevertInput entity if no
792+
// review comment is added.
793+
//
794+
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#revert-change
795+
func (s *ChangesService) RevertChange(changeID string, input *RevertInput) (*ChangeInfo, *Response, error) {
796+
u := fmt.Sprintf("changes/%s/revert", changeID)
797+
798+
req, err := s.client.NewRequest("POST", u, input)
799+
if err != nil {
800+
return nil, nil, err
801+
}
802+
803+
v := new(ChangeInfo)
804+
805+
resp, err := s.client.Do(req, v)
806+
if resp.StatusCode == http.StatusConflict {
807+
body, _ := ioutil.ReadAll(resp.Body)
808+
err = errors.New(string(body[:]))
809+
}
810+
return v, resp, err
811+
}
789812

790-
/*
791-
Missing Change Endpoints
792-
Revert Change
793-
*/

0 commit comments

Comments
 (0)