Skip to content

Commit 1985243

Browse files
committed
added comments to exported function and formatted.
1 parent f5a8364 commit 1985243

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

routers/api/v1/repo/tree.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import (
88
"fmt"
99
"strings"
1010

11-
"code.gitea.io/gitea/modules/setting"
12-
"code.gitea.io/gitea/modules/context"
1311
"code.gitea.io/git"
12+
"code.gitea.io/gitea/modules/context"
13+
"code.gitea.io/gitea/modules/setting"
1414
"code.gitea.io/sdk/gitea"
1515
)
1616

17+
// GetTree get the tree of a repository.
1718
func GetTree(ctx *context.APIContext) {
1819
sha := ctx.Params("sha")
1920
if len(sha) == 0 {
@@ -28,9 +29,10 @@ func GetTree(ctx *context.APIContext) {
2829
}
2930
}
3031

32+
// GetTreeBySHA get the GitTreeResponse of a repository using a sha hash.
3133
func GetTreeBySHA(ctx *context.APIContext, sha string) *gitea.GitTreeResponse {
3234
gitTree, err := ctx.Repo.GitRepo.GetTree(sha)
33-
if err != nil || gitTree == nil{
35+
if err != nil || gitTree == nil {
3436
return nil
3537
}
3638
tree := new(gitea.GitTreeResponse)
@@ -49,12 +51,12 @@ func GetTreeBySHA(ctx *context.APIContext, sha string) *gitea.GitTreeResponse {
4951
repoIDLen := len(repoID)
5052

5153
// 51 is len(sha1) + len("/git/blobs/"). 40 + 11.
52-
blobURL := make([]byte, repoIDLen+ 51)
54+
blobURL := make([]byte, repoIDLen+51)
5355
copy(blobURL[:], repoID)
5456
copy(blobURL[repoIDLen:], "/git/blobs/")
5557

5658
// 51 is len(sha1) + len("/git/trees/"). 40 + 11.
57-
treeURL := make([]byte, repoIDLen+ 51)
59+
treeURL := make([]byte, repoIDLen+51)
5860
copy(treeURL[:], repoID)
5961
copy(treeURL[repoIDLen:], "/git/trees/")
6062

0 commit comments

Comments
 (0)