Skip to content

Commit 0412c6f

Browse files
committed
add RebaseChange
1 parent aeec1e9 commit 0412c6f

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

CHANGELOG.md

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

1010
### 0.5.1
1111

12-
* Added the `AbandonChange` function.
12+
* Added the `AbandonChange` and `RebaseChange` functions.
1313

1414
### 0.5.0
1515

changes.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,9 @@ func (s *ChangesService) SubmitChange(changeID string, input *SubmitInput) (*Cha
716716

717717
// AbandonChange abandons a change.
718718
//
719+
// The request body does not need to include a AbandonInput entity if no review
720+
// comment is added.
721+
//
719722
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#abandon-change
720723
func (s *ChangesService) AbandonChange(changeID string, input *AbandonInput) (*ChangeInfo, *Response, error) {
721724
u := fmt.Sprintf("changes/%s/abandon", changeID)
@@ -735,9 +738,32 @@ func (s *ChangesService) AbandonChange(changeID string, input *AbandonInput) (*C
735738
return v, resp, err
736739
}
737740

741+
// RebaseChange rebases a change.
742+
//
743+
// Optionally, the parent revision can be changed to another patch set through
744+
// the RebaseInput entity.
745+
//
746+
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#rebase-change
747+
func (s *ChangesService) RebaseChange(changeID string, input *RebaseInput) (*ChangeInfo, *Response, error) {
748+
u := fmt.Sprintf("changes/%s/rebase", changeID)
749+
750+
req, err := s.client.NewRequest("POST", u, input)
751+
if err != nil {
752+
return nil, nil, err
753+
}
754+
755+
v := new(ChangeInfo)
756+
757+
resp, err := s.client.Do(req, v)
758+
if resp.StatusCode == http.StatusConflict {
759+
body, _ := ioutil.ReadAll(resp.Body)
760+
err = errors.New(string(body[:]))
761+
}
762+
return v, resp, err
763+
}
764+
738765
/*
739766
Missing Change Endpoints
740767
Restore Change
741-
Rebase Change
742768
Revert Change
743769
*/

0 commit comments

Comments
 (0)