Skip to content

Commit a1f11a0

Browse files
authored
Load Repo Topics on blame view (#11307)
Fix #11280
1 parent d9de58b commit a1f11a0

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

routers/repo/blame.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ func RefBlame(ctx *context.Context) {
194194
commitNames[c.ID.String()] = c
195195
}
196196

197+
// Get Topics of this repo
198+
renderRepoTopics(ctx)
199+
if ctx.Written() {
200+
return
201+
}
202+
197203
renderBlame(ctx, blameParts, commitNames)
198204

199205
ctx.HTML(200, tplBlame)

routers/repo/view.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,17 @@ func renderLanguageStats(ctx *context.Context) {
621621
ctx.Data["LanguageStats"] = langs
622622
}
623623

624+
func renderRepoTopics(ctx *context.Context) {
625+
topics, err := models.FindTopics(&models.FindTopicOptions{
626+
RepoID: ctx.Repo.Repository.ID,
627+
})
628+
if err != nil {
629+
ctx.ServerError("models.FindTopics", err)
630+
return
631+
}
632+
ctx.Data["Topics"] = topics
633+
}
634+
624635
func renderCode(ctx *context.Context) {
625636
ctx.Data["PageIsViewCode"] = true
626637

@@ -645,14 +656,10 @@ func renderCode(ctx *context.Context) {
645656
}
646657

647658
// Get Topics of this repo
648-
topics, err := models.FindTopics(&models.FindTopicOptions{
649-
RepoID: ctx.Repo.Repository.ID,
650-
})
651-
if err != nil {
652-
ctx.ServerError("models.FindTopics", err)
659+
renderRepoTopics(ctx)
660+
if ctx.Written() {
653661
return
654662
}
655-
ctx.Data["Topics"] = topics
656663

657664
// Get current entry user currently looking at.
658665
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(ctx.Repo.TreePath)

0 commit comments

Comments
 (0)