mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-26 11:04:27 -04:00
fix
This commit is contained in:
parent
fd19585760
commit
08bf2d64fd
@ -834,10 +834,8 @@ func GetContentsExt(ctx *context.APIContext) {
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
treePath := ctx.PathParam("*")
|
||||
if treePath == "." || treePath == "/" {
|
||||
treePath = ""
|
||||
ctx.SetPathParam("*", treePath)
|
||||
if treePath := ctx.PathParam("*"); treePath == "." || treePath == "/" {
|
||||
ctx.SetPathParam("*", "") // workaround for swagger, it requires path parameter to be "required", but we need to list root directory
|
||||
}
|
||||
opts := files_service.GetContentsOrListOptions{TreePath: ctx.PathParam("*")}
|
||||
for includeOpt := range strings.SplitSeq(ctx.FormString("includes"), ",") {
|
||||
|
@ -22,7 +22,12 @@ import (
|
||||
func GetContentsListFromTreePaths(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, refCommit *utils.RefCommit, treePaths []string) (files []*api.ContentsResponse) {
|
||||
var size int64
|
||||
for _, treePath := range treePaths {
|
||||
fileContents, _ := GetFileContents(ctx, repo, gitRepo, refCommit, GetContentsOrListOptions{TreePath: treePath, IncludeSingleFileContent: true}) // ok if fails, then will be nil
|
||||
// ok if fails, then will be nil
|
||||
fileContents, _ := GetFileContents(ctx, repo, gitRepo, refCommit, GetContentsOrListOptions{
|
||||
TreePath: treePath,
|
||||
IncludeSingleFileContent: true,
|
||||
IncludeCommitMetadata: true,
|
||||
})
|
||||
if fileContents != nil && fileContents.Content != nil && *fileContents.Content != "" {
|
||||
// if content isn't empty (e.g., due to the single blob being too large), add file size to response size
|
||||
size += int64(len(*fileContents.Content))
|
||||
|
@ -58,8 +58,8 @@ func normalizeFileContentResponseCommitTime(c *api.ContentsResponse) {
|
||||
}
|
||||
|
||||
type apiFileResponseInfo struct {
|
||||
repoFullName, commitID, treePath, lastCommitSHA, lastCommitMessage string
|
||||
lastCommitterWhen, lastAuthorWhen time.Time
|
||||
repoFullName, commitID, treePath, lastCommitSHA string
|
||||
lastCommitterWhen, lastAuthorWhen time.Time
|
||||
}
|
||||
|
||||
func getExpectedFileResponseForCreate(info apiFileResponseInfo) *api.FileResponse {
|
||||
@ -78,7 +78,6 @@ func getExpectedFileResponseForCreate(info apiFileResponseInfo) *api.FileRespons
|
||||
LastCommitSHA: util.ToPointer(info.lastCommitSHA),
|
||||
LastCommitterDate: util.ToPointer(info.lastCommitterWhen),
|
||||
LastAuthorDate: util.ToPointer(info.lastAuthorWhen),
|
||||
LastCommitMessage: util.ToPointer(info.lastCommitMessage),
|
||||
Size: 16,
|
||||
Type: "file",
|
||||
Encoding: &encoding,
|
||||
@ -195,7 +194,6 @@ func TestAPICreateFile(t *testing.T) {
|
||||
lastCommitSHA: lastCommit.ID.String(),
|
||||
lastCommitterWhen: lastCommit.Committer.When,
|
||||
lastAuthorWhen: lastCommit.Author.When,
|
||||
lastCommitMessage: lastCommit.Message(),
|
||||
})
|
||||
var fileResponse api.FileResponse
|
||||
DecodeJSON(t, resp, &fileResponse)
|
||||
|
Loading…
x
Reference in New Issue
Block a user