fix: avoid markup render panic (#38698)

fix #38697

The root problem is that "commitChecker.repo" can be nil when the render
is called without a real repo.
This commit is contained in:
wxiaoguang
2026-07-29 20:26:21 +00:00
committed by GitHub
parent 43390e802c
commit f34073b887
5 changed files with 38 additions and 50 deletions
+1 -1
View File
@@ -51,10 +51,10 @@ func NewRenderContextRepoComment(ctx context.Context, repo *repo_model.Repositor
helper := &RepoComment{opts: util.OptionalArg(opts)}
rctx := markup.NewRenderContext(ctx)
helper.ctx = rctx
helper.commitChecker = newCommitChecker(ctx, repo)
var metas map[string]string
if repo != nil {
helper.repoLink = repo.Link()
helper.commitChecker = newCommitChecker(ctx, repo)
metas = repo.ComposeCommentMetas(ctx)
} else {
// repo can be nil when rendering a commit message in user's dashboard feedback whose repository has been deleted