added recursive support to git trees api (#130)

This commit is contained in:
Kasi Reddy 2018-11-26 08:37:07 +00:00 committed by Lauris BH
parent 545830e497
commit d95a6e0392
1 changed files with 6 additions and 2 deletions

View File

@ -28,8 +28,12 @@ type GitTreeResponse struct {
// GetTrees downloads a file of repository, ref can be branch/tag/commit.
// e.g.: ref -> master, tree -> macaron.go(no leading slash)
func (c *Client) GetTrees(user, repo, ref string) (*GitTreeResponse, error) {
func (c *Client) GetTrees(user, repo, ref string, recursive bool) (*GitTreeResponse, error) {
var trees GitTreeResponse
_, err := c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/git/trees/%s", user, repo, ref), nil, nil)
var path = fmt.Sprintf("/repos/%s/%s/git/trees/%s", user, repo, ref)
if recursive {
path += "?recursive=1"
}
err := c.getParsedResponse("GET", path, nil, nil, &trees)
return &trees, err
}