fix submodule is nil panic (#23588)

#23587  
submodule path is nil 
It is panic a nil error

---------

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
This commit is contained in:
来自村里的小螃蟹 2023-03-21 06:26:01 +08:00 committed by GitHub
parent a8c30a45fa
commit f83246edb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -214,8 +214,10 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref
if err != nil {
return nil, err
}
if submodule != nil && submodule.URL != "" {
contentsResponse.SubmoduleGitURL = &submodule.URL
}
}
// Handle links
if entry.IsRegular() || entry.IsLink() {
downloadURL, err := url.Parse(repo.HTMLURL() + "/raw/" + url.PathEscape(string(refType)) + "/" + util.PathEscapeSegments(ref) + "/" + util.PathEscapeSegments(treePath))