aboutsummaryrefslogtreecommitdiffstats
path: root/modules/repofiles/tree.go
diff options
context:
space:
mode:
authorkolaente <konrad@kola-entertainments.de>2019-06-12 21:41:28 +0200
committertechknowlogick <techknowlogick@gitea.io>2019-06-12 15:41:28 -0400
commitf9ec2f89f2265bc1371a6c62359de9816534fa6b (patch)
treef48b138a457e5ac6cf843bbb38400926704370f7 /modules/repofiles/tree.go
parent5832f8d90df2d72cb38698c3e9050f2b29717dc7 (diff)
downloadgitea-f9ec2f89f2265bc1371a6c62359de9816534fa6b.tar.gz
gitea-f9ec2f89f2265bc1371a6c62359de9816534fa6b.zip
Add golangci (#6418)
Diffstat (limited to 'modules/repofiles/tree.go')
-rw-r--r--modules/repofiles/tree.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/modules/repofiles/tree.go b/modules/repofiles/tree.go
index 4eb54a2598..318a5d152d 100644
--- a/modules/repofiles/tree.go
+++ b/modules/repofiles/tree.go
@@ -16,6 +16,9 @@ import (
// GetTreeBySHA get the GitTreeResponse of a repository using a sha hash.
func GetTreeBySHA(repo *models.Repository, sha string, page, perPage int, recursive bool) (*api.GitTreeResponse, error) {
gitRepo, err := git.OpenRepository(repo.RepoPath())
+ if err != nil {
+ return nil, err
+ }
gitTree, err := gitRepo.GetTree(sha)
if err != nil || gitTree == nil {
return nil, models.ErrSHANotFound{
@@ -39,12 +42,12 @@ func GetTreeBySHA(repo *models.Repository, sha string, page, perPage int, recurs
// 51 is len(sha1) + len("/git/blobs/"). 40 + 11.
blobURL := make([]byte, apiURLLen+51)
- copy(blobURL[:], apiURL)
+ copy(blobURL, apiURL)
copy(blobURL[apiURLLen:], "/git/blobs/")
// 51 is len(sha1) + len("/git/trees/"). 40 + 11.
treeURL := make([]byte, apiURLLen+51)
- copy(treeURL[:], apiURL)
+ copy(treeURL, apiURL)
copy(treeURL[apiURLLen:], "/git/trees/")
// 40 is the size of the sha1 hash in hexadecimal format.
@@ -83,10 +86,10 @@ func GetTreeBySHA(repo *models.Repository, sha string, page, perPage int, recurs
if entries[e].IsDir() {
copy(treeURL[copyPos:], entries[e].ID.String())
- tree.Entries[i].URL = string(treeURL[:])
+ tree.Entries[i].URL = string(treeURL)
} else {
copy(blobURL[copyPos:], entries[e].ID.String())
- tree.Entries[i].URL = string(blobURL[:])
+ tree.Entries[i].URL = string(blobURL)
}
}
return tree, nil