@@ -8,12 +8,13 @@ import (
8
8
"fmt"
9
9
"strings"
10
10
11
- "code.gitea.io/gitea/modules/setting"
12
- "code.gitea.io/gitea/modules/context"
13
11
"code.gitea.io/git"
12
+ "code.gitea.io/gitea/modules/context"
13
+ "code.gitea.io/gitea/modules/setting"
14
14
"code.gitea.io/sdk/gitea"
15
15
)
16
16
17
+ // GetTree get the tree of a repository.
17
18
func GetTree (ctx * context.APIContext ) {
18
19
sha := ctx .Params ("sha" )
19
20
if len (sha ) == 0 {
@@ -28,9 +29,10 @@ func GetTree(ctx *context.APIContext) {
28
29
}
29
30
}
30
31
32
+ // GetTreeBySHA get the GitTreeResponse of a repository using a sha hash.
31
33
func GetTreeBySHA (ctx * context.APIContext , sha string ) * gitea.GitTreeResponse {
32
34
gitTree , err := ctx .Repo .GitRepo .GetTree (sha )
33
- if err != nil || gitTree == nil {
35
+ if err != nil || gitTree == nil {
34
36
return nil
35
37
}
36
38
tree := new (gitea.GitTreeResponse )
@@ -49,12 +51,12 @@ func GetTreeBySHA(ctx *context.APIContext, sha string) *gitea.GitTreeResponse {
49
51
repoIDLen := len (repoID )
50
52
51
53
// 51 is len(sha1) + len("/git/blobs/"). 40 + 11.
52
- blobURL := make ([]byte , repoIDLen + 51 )
54
+ blobURL := make ([]byte , repoIDLen + 51 )
53
55
copy (blobURL [:], repoID )
54
56
copy (blobURL [repoIDLen :], "/git/blobs/" )
55
57
56
58
// 51 is len(sha1) + len("/git/trees/"). 40 + 11.
57
- treeURL := make ([]byte , repoIDLen + 51 )
59
+ treeURL := make ([]byte , repoIDLen + 51 )
58
60
copy (treeURL [:], repoID )
59
61
copy (treeURL [repoIDLen :], "/git/trees/" )
60
62
0 commit comments