forked from Gitlink/gitea-1156
This commit is contained in:
parent
db945157cd
commit
6eefa22e78
|
@ -761,20 +761,16 @@ func GetReadmeContents(ctx *context.APIContext) {
|
|||
|
||||
// treePath := ctx.Params("*")
|
||||
ref := ctx.QueryTrim("ref")
|
||||
var readmePath string
|
||||
readmePath := "README.md"
|
||||
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
|
||||
}
|
||||
if readmePath != "" {
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
readmePath = "README.md"
|
||||
}
|
||||
|
||||
if fileList, err := repofiles.GetContentsOrList(ctx, ctx.Repo.Repository, readmePath, ref); err != nil {
|
||||
|
@ -831,20 +827,16 @@ func GetReadmeContentsByPath(ctx *context.APIContext) {
|
|||
|
||||
treePath := ctx.Params("*")
|
||||
ref := ctx.QueryTrim("ref")
|
||||
var readmePath string
|
||||
readmePath := "README.md"
|
||||
filesListInterface, _ := repofiles.GetContentsOrList(ctx, ctx.Repo.Repository, treePath, ref)
|
||||
filesList, ok := filesListInterface.([]*api.ContentsResponse)
|
||||
if ok {
|
||||
for _, file := range filesList {
|
||||
if strings.ToLower(file.Name) == "readme.md" {
|
||||
readmePath = file.Name
|
||||
}
|
||||
if readmePath != "" {
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
readmePath = "README.md"
|
||||
}
|
||||
newTreePath := treePath + "/" + readmePath
|
||||
if fileList, err := repofiles.GetContentsOrList(ctx, ctx.Repo.Repository, newTreePath, ref); err != nil {
|
||||
|
|
Loading…
Reference in New Issue