mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Add golangci (#6418)
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user