Skip to content
This repository was archived by the owner on Jun 8, 2019. It is now read-only.

Commit 545830e

Browse files
lunnylafriks
authored andcommitted
Add repo trees (#94)
* add repo trees * Update copyright
1 parent 59ddbdc commit 545830e

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

gitea/repo_tree.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2018 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package gitea
6+
7+
import (
8+
"fmt"
9+
)
10+
11+
// GitEntry represents a git tree
12+
type GitEntry struct {
13+
Path string `json:"path"`
14+
Mode string `json:"mode"`
15+
Type string `json:"type"`
16+
Size int64 `json:"size"`
17+
SHA string `json:"sha"`
18+
URL string `json:"url"`
19+
}
20+
21+
// GitTreeResponse returns a git tree
22+
type GitTreeResponse struct {
23+
SHA string `json:"sha"`
24+
URL string `json:"url"`
25+
Entries []GitEntry `json:"tree"`
26+
Truncated bool `json:"truncated"`
27+
}
28+
29+
// GetTrees downloads a file of repository, ref can be branch/tag/commit.
30+
// e.g.: ref -> master, tree -> macaron.go(no leading slash)
31+
func (c *Client) GetTrees(user, repo, ref string) (*GitTreeResponse, error) {
32+
var trees GitTreeResponse
33+
_, err := c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/git/trees/%s", user, repo, ref), nil, nil)
34+
return &trees, err
35+
}

0 commit comments

Comments
 (0)