29 lines
976 B
Go
29 lines
976 B
Go
package files
|
|
|
|
import (
|
|
"context"
|
|
|
|
repo_model "code.gitea.io/gitea/models/repo"
|
|
"code.gitea.io/gitea/modules/git"
|
|
gitea_files_service "code.gitea.io/gitea/services/repository/files"
|
|
hat_api "code.gitlink.org.cn/Gitlink/gitea_hat.git/modules/structs"
|
|
)
|
|
|
|
func GetBatchFileResponseFromCommit(ctx context.Context, repo *repo_model.Repository, commit *git.Commit, branch string, treeNames []string) (*hat_api.BatchFileResponse, error) {
|
|
fileCommitResponse, _ := gitea_files_service.GetFileCommitResponse(repo, commit)
|
|
verification := gitea_files_service.GetPayloadCommitVerification(commit)
|
|
batchFileResponse := &hat_api.BatchFileResponse{
|
|
Commit: fileCommitResponse,
|
|
Verification: verification,
|
|
}
|
|
for _, treeName := range treeNames {
|
|
fileContent, _ := GetContents(ctx, repo, treeName, branch, false)
|
|
if fileContent == nil {
|
|
continue
|
|
}
|
|
batchFileResponse.Contents = append(batchFileResponse.Contents, fileContent)
|
|
}
|
|
|
|
return batchFileResponse, nil
|
|
}
|