2018-11-24 11:03:22 +00:00
|
|
|
// Copyright 2018 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package gitea
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2019-05-11 16:38:52 +01:00
|
|
|
"code.gitea.io/gitea/modules/structs"
|
|
|
|
)
|
2018-11-24 11:03:22 +00:00
|
|
|
|
|
|
|
// GetTrees downloads a file of repository, ref can be branch/tag/commit.
|
|
|
|
// e.g.: ref -> master, tree -> macaron.go(no leading slash)
|
2019-05-11 16:38:52 +01:00
|
|
|
func (c *Client) GetTrees(user, repo, ref string, recursive bool) (*structs.GitTreeResponse, error) {
|
|
|
|
var trees structs.GitTreeResponse
|
2018-11-26 08:37:07 +00:00
|
|
|
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)
|
2018-11-24 11:03:22 +00:00
|
|
|
return &trees, err
|
|
|
|
}
|