This repository has been archived by the owner on Jul 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
git_trees.go
49 lines (42 loc) · 1.57 KB
/
git_trees.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package octokit
import (
"net/url"
)
// GitTreesURL is a template for accessing git trees at a particular sha hash or branch
// of a particular repository of a particular owner. The request may be set to be
// recursive for a particular level of depth (0 is no recursion) to follow sub-trees from
// the primary repository.
var GitTreesURL = Hyperlink("repos/{owner}/{repo}/git/trees/{sha}{?recursive}")
// GitTrees creates a GitTreesService with a base url
func (c *Client) GitTrees(url *url.URL) (trees *GitTreesService) {
trees = &GitTreesService{client: c, URL: url}
return
}
// GitTreesService is a service providing access to GitTrees from a particular url
type GitTreesService struct {
client *Client
URL *url.URL
}
// One gets a specific GitTree based on the url of the service
func (c *GitTreesService) One() (tree *GitTree, result *Result) {
result = c.client.get(c.URL, &tree)
return
}
// GitTree represents a tree on GitHub, a level in the GitHub equivalent of a
// directory structure
type GitTree struct {
Sha string `json:"sha,omitempty"`
Tree []GitTreeEntry `json:"tree,omitempty"`
Truncated bool `json:"truncated,omitempty"`
URL string `json:"url,omitempty"`
}
// GitTreeEntry represents an element within a GitTree on GitHub, which may either
// be another Tree or a single Blob
type GitTreeEntry struct {
Mode string `json:"mode,omitempty"`
Path string `json:"path,omitempty"`
Sha string `json:"sha,omitempty"`
Size int `json:"size,omitempty"`
Type string `json:"type,omitempty"`
URL string `json:"url,omitempty"`
}