From f83246edb263c039904ee9723f5dfc2a46f2259f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A5=E8=87=AA=E6=9D=91=E9=87=8C=E7=9A=84=E5=B0=8F?= =?UTF-8?q?=E8=9E=83=E8=9F=B9?= Date: Tue, 21 Mar 2023 06:26:01 +0800 Subject: [PATCH] fix submodule is nil panic (#23588) #23587 submodule path is nil It is panic a nil error --------- Co-authored-by: delvh Co-authored-by: KN4CK3R --- services/repository/files/content.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/repository/files/content.go b/services/repository/files/content.go index 31827e8846ed..6f6dc91d859a 100644 --- a/services/repository/files/content.go +++ b/services/repository/files/content.go @@ -214,7 +214,9 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref if err != nil { return nil, err } - contentsResponse.SubmoduleGitURL = &submodule.URL + if submodule != nil && submodule.URL != "" { + contentsResponse.SubmoduleGitURL = &submodule.URL + } } // Handle links if entry.IsRegular() || entry.IsLink() {