新增:readme文件默认使用中文readme文件

This commit is contained in:
yystopf 2022-09-21 19:16:34 +08:00
parent 7134770a03
commit 2834ba8281
1 changed files with 8 additions and 1 deletions

View File

@ -762,17 +762,24 @@ func GetReadmeContents(ctx *context.APIContext) {
// treePath := ctx.Params("*")
ref := ctx.QueryTrim("ref")
readmePath := "README.md"
readmezhPath := ""
filesListInterface, _ := repofiles.GetContentsOrList(ctx, ctx.Repo.Repository, "", ref)
filesList, ok := filesListInterface.([]*api.ContentsResponse)
if ok {
for _, file := range filesList {
if strings.ToLower(file.Name) == "readme.md" {
readmePath = file.Name
break
}
if strings.ToLower(file.Name) == "readme_zh.md" {
readmezhPath = file.Name
}
}
}
if readmezhPath != "" {
readmePath = readmezhPath
}
if fileList, err := repofiles.GetContentsOrList(ctx, ctx.Repo.Repository, readmePath, ref); err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("GetContentsOrList", err)