gitiles: support the b= argument for repository listing. Change-Id: Ic0b72d1ad7e56439fe4fae2e656f589d6d7a32a3
diff --git a/gitiles/client.go b/gitiles/client.go index 27a04fd..86845e3 100644 --- a/gitiles/client.go +++ b/gitiles/client.go
@@ -116,9 +116,12 @@ } // List retrieves the list of projects. -func (s *Service) List() (map[string]*Project, error) { +func (s *Service) List(branches []string) (map[string]*Project, error) { listURL := s.addr listURL.RawQuery = "format=JSON" + for _, b := range branches { + listURL.RawQuery += "&b=" + b + } projects := map[string]*Project{} err := s.getJSON(&listURL, &projects)
diff --git a/gitiles/types.go b/gitiles/types.go index 99f29fa..b10ecbc 100644 --- a/gitiles/types.go +++ b/gitiles/types.go
@@ -17,8 +17,10 @@ import "fmt" type Project struct { - Name string - CloneURL string `json:"clone_url"` + Name string + CloneURL string `json:"clone_url"` + Description string `json:"description"` + Branches map[string]string `json:"branches"` } type Person struct {
diff --git a/gitiles/types_test.go b/gitiles/types_test.go index 5bb9845..26d4c2a 100644 --- a/gitiles/types_test.go +++ b/gitiles/types_test.go
@@ -236,17 +236,27 @@ }, { in: `{ - "accessories/manifest": { - "name": "accessories/manifest", - "clone_url": "https://android.googlesource.com/accessories/manifest" + "plugins/oauth": { + "name": "plugins/oauth", + "clone_url": "https://gerrit.googlesource.com/plugins/oauth", + "description": "OAuth provider for GitHub and Google", + "branches": { + "master": "56fbd4c28ba35877a38ec4c6bbfc6b5920db4207", + "stable-2.10": "5d404e6c38ff380a3b8964c1343fb91b8ec6bb76" + } } } `, want: &map[string]*Project{ - "accessories/manifest": &Project{ - Name: "accessories/manifest", - CloneURL: "https://android.googlesource.com/accessories/manifest", - }}, + "plugins/oauth": &Project{ + Name: "plugins/oauth", + CloneURL: "https://gerrit.googlesource.com/plugins/oauth", + Description: "OAuth provider for GitHub and Google", + Branches: map[string]string{ + "master": "56fbd4c28ba35877a38ec4c6bbfc6b5920db4207", + "stable-2.10": "5d404e6c38ff380a3b8964c1343fb91b8ec6bb76", + }}, + }, got: &map[string]*Project{}, }, }