jiri/gerrit: get cl data about modified files.
MultiPart: 2/2
Change-Id: Ie2000dba223234c991a92f34f273c4bf7c2d7631
diff --git a/gerrit/.api b/gerrit/.api
index ee305d2..8663acb 100644
--- a/gerrit/.api
+++ b/gerrit/.api
@@ -41,6 +41,7 @@
pkg gerrit, type Commit struct, Message string
pkg gerrit, type Fetch struct
pkg gerrit, type Fetch struct, embedded Http
+pkg gerrit, type Files map[string]struct{}
pkg gerrit, type Gerrit struct
pkg gerrit, type Http struct
pkg gerrit, type Http struct, Ref string
@@ -58,6 +59,7 @@
pkg gerrit, type Revision struct
pkg gerrit, type Revision struct, embedded Commit
pkg gerrit, type Revision struct, embedded Fetch
+pkg gerrit, type Revision struct, embedded Files
pkg gerrit, type Revisions map[string]Revision
pkg gerrit, type Topic struct
pkg gerrit, type Topic struct, Topic string
diff --git a/gerrit/gerrit.go b/gerrit/gerrit.go
index 08f96f2..efd7f1c 100644
--- a/gerrit/gerrit.go
+++ b/gerrit/gerrit.go
@@ -31,6 +31,8 @@
remoteRE = regexp.MustCompile("remote:[^\n]*")
multiPartRE = regexp.MustCompile(`MultiPart:\s*(\d+)\s*/\s*(\d+)`)
presubmitTestRE = regexp.MustCompile(`PresubmitTest:\s*(.*)`)
+
+ queryParameters = []string{"CURRENT_REVISION", "CURRENT_COMMIT", "CURRENT_FILES", "LABELS", "DETAILED_ACCOUNTS"}
)
// Comment represents a single inline file comment.
@@ -195,6 +197,7 @@
type Revision struct {
Fetch `json:"fetch"`
Commit `json:"commit"`
+ Files `json:"files"`
}
type Fetch struct {
Http `json:"http"`
@@ -208,6 +211,7 @@
type Owner struct {
Email string
}
+type Files map[string]struct{}
func (c Change) Reference() string {
return c.Revisions[c.Current_revision].Fetch.Http.Ref
@@ -322,7 +326,19 @@
return nil, err
}
- url := fmt.Sprintf("%s/a/changes/?o=CURRENT_REVISION&o=CURRENT_COMMIT&o=LABELS&o=DETAILED_ACCOUNTS&q=%s", g.host, url.QueryEscape(query))
+ u, err := url.Parse(g.host.String())
+ if err != nil {
+ return nil, err
+ }
+ u.Path = "/a/changes/"
+ v := url.Values{}
+ v.Set("q", query)
+ for _, o := range queryParameters {
+ v.Add("o", o)
+ }
+ u.RawQuery = v.Encode()
+ url := u.String()
+
var body io.Reader
method, body := "GET", nil
req, err := http.NewRequest(method, url, body)