Skip to content

Commit

Permalink
Load Repo Topics on blame view (#11307)
Browse files Browse the repository at this point in the history
Fix #11280
  • Loading branch information
6543 committed May 5, 2020
1 parent d9de58b commit a1f11a0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
6 changes: 6 additions & 0 deletions routers/repo/blame.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ func RefBlame(ctx *context.Context) {
commitNames[c.ID.String()] = c
}

// Get Topics of this repo
renderRepoTopics(ctx)
if ctx.Written() {
return
}

renderBlame(ctx, blameParts, commitNames)

ctx.HTML(200, tplBlame)
Expand Down
19 changes: 13 additions & 6 deletions routers/repo/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,17 @@ func renderLanguageStats(ctx *context.Context) {
ctx.Data["LanguageStats"] = langs
}

func renderRepoTopics(ctx *context.Context) {
topics, err := models.FindTopics(&models.FindTopicOptions{
RepoID: ctx.Repo.Repository.ID,
})
if err != nil {
ctx.ServerError("models.FindTopics", err)
return
}
ctx.Data["Topics"] = topics
}

func renderCode(ctx *context.Context) {
ctx.Data["PageIsViewCode"] = true

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

// Get Topics of this repo
topics, err := models.FindTopics(&models.FindTopicOptions{
RepoID: ctx.Repo.Repository.ID,
})
if err != nil {
ctx.ServerError("models.FindTopics", err)
renderRepoTopics(ctx)
if ctx.Written() {
return
}
ctx.Data["Topics"] = topics

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

0 comments on commit a1f11a0

Please sign in to comment.