From ac0215c68afe88c36216eada3b8c06fd6c2204a6 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Tue, 23 May 2023 09:25:27 +0200 Subject: [PATCH] Fix Bug in Explore when Repo has no Owner --- models/repo/repo_list.go | 6 +++++- templates/explore/repo_list.tmpl | 12 +++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/models/repo/repo_list.go b/models/repo/repo_list.go index 92b9c15b4bd8d..de6b8cdf84a29 100644 --- a/models/repo/repo_list.go +++ b/models/repo/repo_list.go @@ -84,7 +84,11 @@ func (repos RepositoryList) LoadAttributes(ctx context.Context) error { return fmt.Errorf("find users: %w", err) } for i := range repos { - repos[i].Owner = users[repos[i].OwnerID] + if users[repos[i].OwnerID] != nil { + repos[i].Owner = users[repos[i].OwnerID] + } else { + repos[i].Owner = user_model.NewGhostUser() + } } // Load primary language. diff --git a/templates/explore/repo_list.tmpl b/templates/explore/repo_list.tmpl index b311472b43ed2..b5872d487b491 100644 --- a/templates/explore/repo_list.tmpl +++ b/templates/explore/repo_list.tmpl @@ -7,9 +7,15 @@ {{if $avatar}} {{$avatar}} {{end}} - - {{if or $.PageIsExplore $.PageIsProfileStarList}}{{if .Owner}}{{.Owner.Name}} / {{end}}{{end}}{{.Name}} - + {{if not .Owner.IsGhost}} + + {{if or $.PageIsExplore $.PageIsProfileStarList}}{{if .Owner}}{{.Owner.Name}} / {{end}}{{end}}{{.Name}} + + {{else}} + + {{if or $.PageIsExplore $.PageIsProfileStarList}}{{if .Owner}}{{.Owner.Name}} / {{end}}{{end}}{{.Name}} + + {{end}}
{{if .IsArchived}} {{$.locale.Tr "repo.desc.archived"}}