Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Submit Change #15

Merged
merged 1 commit into from
Sep 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion changes.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package gerrit

import (
"errors"
"fmt"
"io/ioutil"
)

// ChangesService contains Change related REST endpoints
Expand Down Expand Up @@ -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
*/