diff options
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/repo/view.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 5bf961f412..9cd5fc9e40 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -58,7 +58,7 @@ const ( // entries == ctx.Repo.Commit.SubTree(ctx.Repo.TreePath).ListEntries() // // FIXME: There has to be a more efficient way of doing this -func findReadmeFileInEntries(ctx *context.Context, entries []*git.TreeEntry) (string, *git.TreeEntry, error) { +func findReadmeFileInEntries(ctx *context.Context, entries []*git.TreeEntry, tryWellKnownDirs bool) (string, *git.TreeEntry, error) { // Create a list of extensions in priority order // 1. Markdown files - with and without localisation - e.g. README.en-us.md or README.md // 2. Txt files - e.g. README.txt @@ -69,7 +69,7 @@ func findReadmeFileInEntries(ctx *context.Context, entries []*git.TreeEntry) (st docsEntries := make([]*git.TreeEntry, 3) // (one of docs/, .gitea/ or .github/) for _, entry := range entries { - if entry.IsDir() { + if tryWellKnownDirs && entry.IsDir() { // as a special case for the top-level repo introduction README, // fall back to subfolders, looking for e.g. docs/README.md, .gitea/README.zh-CN.txt, .github/README.txt, ... // (note that docsEntries is ignored unless we are at the root) @@ -130,7 +130,7 @@ func findReadmeFileInEntries(ctx *context.Context, entries []*git.TreeEntry) (st return "", nil, err } - subfolder, readmeFile, err := findReadmeFileInEntries(ctx, childEntries) + subfolder, readmeFile, err := findReadmeFileInEntries(ctx, childEntries, false) if err != nil && !git.IsErrNotExist(err) { return "", nil, err } @@ -164,7 +164,7 @@ func renderDirectory(ctx *context.Context, treeLink string) { return } - subfolder, readmeFile, err := findReadmeFileInEntries(ctx, entries) + subfolder, readmeFile, err := findReadmeFileInEntries(ctx, entries, true) if err != nil { ctx.ServerError("findReadmeFileInEntries", err) return |