From 61d518d0c5333693f8ff9c7041cdff81b17d5928 Mon Sep 17 00:00:00 2001 From: Per Olausson Date: Tue, 27 Sep 2016 15:24:32 +0100 Subject: [PATCH] Add Submit Change --- changes.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/changes.go b/changes.go index 79368d2..5298fa1 100644 --- a/changes.go +++ b/changes.go @@ -1,7 +1,9 @@ package gerrit import ( + "errors" "fmt" + "io/ioutil" ) // ChangesService contains Change related REST endpoints @@ -674,11 +676,28 @@ func (s *ChangesService) FixChange(changeID string, input *FixInput) (*ChangeInf return v, resp, err } +func (s *ChangesService) SubmitChange(changeID string, input *SubmitInput) (*ChangeInfo, *Response, error) { + u := fmt.Sprintf("changes/%s/submit", changeID) + + req, err := s.client.NewRequest("POST", u, input) + if err != nil { + return nil, nil, err + } + + v := new(ChangeInfo) + + resp, err := s.client.Do(req, v) + if 409 == resp.StatusCode { + body, _ := ioutil.ReadAll(resp.Body) + err = errors.New(string(body[:])) + } + return v, resp, err +} + /* Missing Change Endpoints Abandon Change Restore Change Rebase Change Revert Change - Submit Change */