mirror of
https://github.com/go-gitea/gitea
synced 2025-07-21 17:58:35 +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:
@@ -15,8 +15,12 @@ type CommitInfo struct {
|
||||
func getCommitInfoSubmoduleFile(repoLink string, entry *TreeEntry, commit *Commit, treePathDir string) (*CommitSubmoduleFile, error) {
|
||||
fullPath := path.Join(treePathDir, entry.Name())
|
||||
submodule, err := commit.GetSubModule(fullPath)
|
||||
if submodule == nil || err != nil {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if submodule == nil {
|
||||
// unable to find submodule from ".gitmodules" file
|
||||
return NewCommitSubmoduleFile(repoLink, fullPath, "", entry.ID.String()), nil
|
||||
}
|
||||
return NewCommitSubmoduleFile(repoLink, fullPath, submodule.URL, entry.ID.String()), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user