feat(repo): prioritize well-known READMEs and optimize discovery (#38532)

This PR adjusts the repository README discovery logic to mirror GitHub's
priority order, while retaining support for Gitea's specific `.gitea/`
directory.

Previously, Gitea would prioritize a `README.md` at the root of the
repository over any READMEs in `.gitea/` or `.github/`. With this
change, well-known subdirectories are evaluated first when viewing the
repository root.

**New Priority Order:**
1. `.gitea/README.md`
2. `.github/README.md`
3. `/README.md` (root directory)
4. `docs/README.md`

This allows repository maintainers to use `.github/README.md` (or
`.gitea/README.md`) as the repository homepage without having to remove
or rename generic root `/README.md` files required by package managers
(like NPM, Crates.io, Docker, etc.).

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Shudhanshu Singh
2026-07-21 09:14:25 +05:30
committed by GitHub
parent a4526d5a82
commit c0f4e5583e
48 changed files with 248 additions and 231 deletions

View File

@@ -8,6 +8,7 @@ import (
"archive/zip"
"bytes"
"compress/gzip"
"context"
"io"
"net/http"
"net/http/httptest"
@@ -156,6 +157,7 @@ var AllowSkipExternalService = sync.OnceValue(func() bool {
})
type TestingT interface {
Context() context.Context
Helper()
Skipf(format string, args ...any)
Errorf(format string, args ...any)