fix: handle viewing a submodule entry (#7261)
- When trying to view a submodule directory via the normal `/src/branch/` path, generate a redirect link to the submodule location. - Resolves forgejo/forgejo#5267 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7261 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Gnarwhal <git.aspect893@passmail.net> Co-committed-by: Gnarwhal <git.aspect893@passmail.net>
This commit is contained in:
parent
77b0275572
commit
d28a64e538
2 changed files with 15 additions and 1 deletions
|
@ -1044,7 +1044,15 @@ func renderHomeCode(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if entry.IsDir() {
|
||||
if entry.IsSubModule() {
|
||||
subModuleURL, err := ctx.Repo.Commit.GetSubModule(entry.Name())
|
||||
if err != nil {
|
||||
HandleGitError(ctx, "Repo.Commit.GetSubModule", err)
|
||||
return
|
||||
}
|
||||
subModuleFile := git.NewSubModuleFile(ctx.Repo.Commit, subModuleURL, entry.ID.String())
|
||||
ctx.Redirect(subModuleFile.RefURL(setting.AppURL, ctx.Repo.Repository.FullName(), setting.SSH.Domain))
|
||||
} else if entry.IsDir() {
|
||||
renderDirectory(ctx)
|
||||
} else {
|
||||
renderFile(ctx, entry)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue