// post review // POST /changes/{change-id}/revisions/{revision-id}/review func Post(gerrit *api.API, id string, message string, mark int8) (*ReviewReply, error) { change_url := url.URL{Scheme: "https", Host: gerrit.Host, Opaque: "/a/changes/" + id + "/revisions/current/review"} review := ReviewPost{ Message: message, Labels: &ReviewLabels{CodeReview: mark}, } json_str, json_err := json.Marshal(review) if json_err != nil { return nil, json_err } contents, err := gerrit.Post_json(&change_url, json_str) if err != nil { return nil, err } var reply ReviewReply json_err = json.Unmarshal(contents, &reply) if json_err != nil { return nil, json_err } return &reply, nil }
// fetch detailed information about the change func Get(gerrit *api.API, id string) (*LongChange, error) { change_url := url.URL{Scheme: "https", Host: gerrit.Host, Opaque: "/a/changes/" + id + "/detail/"} contents, err := gerrit.Fetch_json(&change_url) if err != nil { return nil, err } var data LongChange err = json.Unmarshal(contents, &data) if err != nil { return nil, err } return &data, nil }
// get list of changes according to the query string func FetchList(gerrit *api.API, query_string string) ([]ShortChange, error) { list_url, _ := url.Parse("https://" + gerrit.Host + "/a/changes/" + query_string) contents, err := gerrit.Fetch_json(list_url) if err != nil { return nil, err } var data []ShortChange err = json.Unmarshal(contents, &data) if err != nil { //fmt.Printf("JSON failed: %s\n", err) //fmt.Printf("JSON data is: %s\n", contents) return nil, err } return data, nil }