[GITEA] repo: Don't redirect the repo to external units

When displaying the repo home view, do not redirect to unit types that
can't be defaults (which, at the moment, are the external wiki and issue
tracker unit types).

If we'd redirect to those, that would mean that a repository with the
Code unit disabled, and an external issue tracker would immediately
redirect to the external issue tracker, making it harder to reach other,
non-external units of the repo.

Fixes #1965.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit 44078e5460)
(cherry picked from commit 1868dec2e4)
This commit is contained in:
Gergely Nagy 2023-12-31 17:54:43 +01:00 committed by Earl Warren
parent 63d086f666
commit c3a8e98870
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
2 changed files with 104 additions and 1 deletions

View file

@ -693,7 +693,7 @@ func checkHomeCodeViewable(ctx *context.Context) {
}
unit, ok := unit_model.Units[repoUnit.Type]
if ok && (firstUnit == nil || !firstUnit.IsLessThan(unit)) {
if ok && (firstUnit == nil || !firstUnit.IsLessThan(unit)) && repoUnit.Type.CanBeDefault() {
firstUnit = &unit
}
}