@@ -48,10 +48,7 @@ type RepoCommentOptions struct {
48
48
}
49
49
50
50
func 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 )}
55
52
rctx := markup .NewRenderContext (ctx )
56
53
helper .ctx = rctx
57
54
var metas map [string ]string
@@ -60,15 +57,16 @@ func NewRenderContextRepoComment(ctx context.Context, repo *repo_model.Repositor
60
57
helper .commitChecker = newCommitChecker (ctx , repo )
61
58
metas = repo .ComposeCommentMetas (ctx )
62
59
} 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"
72
70
}
73
71
metas ["footnoteContextId" ] = helper .opts .FootnoteContextID
74
72
rctx = rctx .WithMetas (metas ).WithHelper (helper )
0 commit comments