forked from Gitlink/gitea-1156
新增:readme文件默认使用中文readme文件
This commit is contained in:
parent
7134770a03
commit
2834ba8281
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue