1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-28 21:28:38 +00:00

Fix submodule parsing when the gitmodules is missing (#35109)

Follow up #35096, fix #35095, fix #35115 and add more tests

The old code used some fragile behaviors which depend on the "nil"
receiver. This PR should be a complete fix for more edge cases.
This commit is contained in:
wxiaoguang
2025-07-18 17:42:44 +08:00
committed by GitHub
parent 13b9659952
commit 8f91bfe9d8
6 changed files with 28 additions and 9 deletions

View File

@@ -259,9 +259,10 @@ func handleRepoEmptyOrBroken(ctx *context.Context) {
}
func handleRepoViewSubmodule(ctx *context.Context, submodule *git.SubModule) {
// TODO: it needs to use git.NewCommitSubmoduleFile and SubmoduleWebLinkTree to correctly handle relative paths
submoduleRepoURL, err := giturl.ParseRepositoryURL(ctx, submodule.URL)
if err != nil {
HandleGitError(ctx, "prepareToRenderDirOrFile: ParseRepositoryURL", err)
HandleGitError(ctx, "handleRepoViewSubmodule: ParseRepositoryURL", err)
return
}
submoduleURL := giturl.MakeRepositoryWebLink(submoduleRepoURL)