@@ -48,10 +48,7 @@ type RepoCommentOptions struct {
4848}
4949
5050func NewRenderContextRepoComment (ctx context.Context , repo * repo_model.Repository , opts ... RepoCommentOptions ) * markup.RenderContext {
51- helper := & RepoComment {
52- repoLink : repo .Link (),
53- opts : util .OptionalArg (opts ),
54- }
51+ helper := & RepoComment {opts : util .OptionalArg (opts )}
5552 rctx := markup .NewRenderContext (ctx )
5653 helper .ctx = rctx
5754 var metas map [string ]string
@@ -60,15 +57,16 @@ func NewRenderContextRepoComment(ctx context.Context, repo *repo_model.Repositor
6057 helper .commitChecker = newCommitChecker (ctx , repo )
6158 metas = repo .ComposeCommentMetas (ctx )
6259 } else {
63- // this is almost dead code, only to pass the incorrect tests
64- helper .repoLink = fmt .Sprintf ("%s/%s" , helper .opts .DeprecatedOwnerName , helper .opts .DeprecatedRepoName )
65- rctx = rctx .WithMetas (map [string ]string {
66- "user" : helper .opts .DeprecatedOwnerName ,
67- "repo" : helper .opts .DeprecatedRepoName ,
68-
69- "markdownNewLineHardBreak" : "true" ,
70- "markupAllowShortIssuePattern" : "true" ,
71- })
60+ // repo can be nil when rendering a commit message in user's dashboard feedback whose repository has been deleted
61+ metas = map [string ]string {}
62+ if helper .opts .DeprecatedOwnerName != "" {
63+ // this is almost dead code, only to pass the incorrect tests
64+ helper .repoLink = fmt .Sprintf ("%s/%s" , helper .opts .DeprecatedOwnerName , helper .opts .DeprecatedRepoName )
65+ metas ["user" ] = helper .opts .DeprecatedOwnerName
66+ metas ["repo" ] = helper .opts .DeprecatedRepoName
67+ }
68+ metas ["markdownNewLineHardBreak" ] = "true"
69+ metas ["markupAllowShortIssuePattern" ] = "true"
7270 }
7371 metas ["footnoteContextId" ] = helper .opts .FootnoteContextID
7472 rctx = rctx .WithMetas (metas ).WithHelper (helper )
0 commit comments