diff --git a/routers/repo/commit.go b/routers/repo/commit.go index 1174e62661..82be6881fa 100644 --- a/routers/repo/commit.go +++ b/routers/repo/commit.go @@ -5,12 +5,14 @@ package repo import ( + "container/list" "path" "github.com/Unknwon/com" "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/base" + "github.com/gogits/gogs/modules/git" "github.com/gogits/gogs/modules/middleware" "github.com/gogits/gogs/modules/setting" ) @@ -72,6 +74,7 @@ func Commits(ctx *middleware.Context) { ctx.Handle(500, "CommitsByRange", err) return } + commits = RenderIssueLinks(commits, ctx.Repo.RepoLink) commits = models.ValidateCommitsWithEmails(commits) ctx.Data["Commits"] = commits @@ -83,6 +86,16 @@ func Commits(ctx *middleware.Context) { ctx.HTML(200, COMMITS) } +func RenderIssueLinks(oldCommits *list.List, repoLink string) *list.List { + newCommits := list.New() + for e := oldCommits.Front(); e != nil; e = e.Next() { + c := e.Value.(*git.Commit) + c.CommitMessage = string(base.RenderissueIndexPattern([]byte(c.CommitMessage), repoLink)) + newCommits.PushBack(c) + } + return newCommits +} + func SearchCommits(ctx *middleware.Context) { ctx.Data["IsSearchPage"] = true ctx.Data["IsRepoToolbarCommits"] = true @@ -110,6 +123,7 @@ func SearchCommits(ctx *middleware.Context) { ctx.Handle(500, "SearchCommits", err) return } + commits = RenderIssueLinks(commits, ctx.Repo.RepoLink) commits = models.ValidateCommitsWithEmails(commits) ctx.Data["Keyword"] = keyword @@ -171,6 +185,7 @@ func FileHistory(ctx *middleware.Context) { ctx.Handle(500, "repo.FileHistory(CommitsByRange)", err) return } + commits = RenderIssueLinks(commits, ctx.Repo.RepoLink) commits = models.ValidateCommitsWithEmails(commits) ctx.Data["Commits"] = commits @@ -191,7 +206,7 @@ func Diff(ctx *middleware.Context) { commitId := ctx.Repo.CommitId commit := ctx.Repo.Commit - + commit.CommitMessage = string(base.RenderissueIndexPattern([]byte(commit.CommitMessage), ctx.Repo.RepoLink)) diff, err := models.GetDiffCommit(models.RepoPath(userName, repoName), commitId, setting.MaxGitDiffLines) if err != nil { diff --git a/routers/repo/view.go b/routers/repo/view.go index 162279acd1..073eb5d74e 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -199,6 +199,7 @@ func Home(ctx *middleware.Context) { } lastCommit := ctx.Repo.Commit + lastCommit.CommitMessage = string(base.RenderissueIndexPattern([]byte(lastCommit.CommitMessage), ctx.Repo.RepoLink)) if len(treePath) > 0 { c, err := ctx.Repo.Commit.GetCommitOfRelPath(treePath) if err != nil { diff --git a/templates/repo/commits_table.tmpl b/templates/repo/commits_table.tmpl index eb819e387f..bd3777b46e 100644 --- a/templates/repo/commits_table.tmpl +++ b/templates/repo/commits_table.tmpl @@ -32,7 +32,7 @@ {{end}} {{SubStr .Id.String 0 10}} - {{.Summary}} + {{Str2html .Summary}} {{TimeSince .Author.When $.Lang}} {{end}} diff --git a/templates/repo/diff.tmpl b/templates/repo/diff.tmpl index 61164c0de0..2726b94d9d 100644 --- a/templates/repo/diff.tmpl +++ b/templates/repo/diff.tmpl @@ -17,7 +17,7 @@
{{.i18n.Tr "repo.diff.browse_source"}} -

{{.Commit.Message}}

+

{{Str2html .Commit.Message}}

diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index d516eac94c..8160c17b83 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -14,7 +14,7 @@ {{ShortSha .LastCommit.Id.String}} - {{.LastCommit.Summary}} + {{Str2html .LastCommit.Summary}} {{TimeSince .LastCommit.Author.When $.Lang}} @@ -25,6 +25,7 @@ .. + SHA1 @@ -48,8 +49,11 @@ {{$entry.Name}} {{end}} - - {{$commit.Summary}} + + {{SubStr $commit.Id.String 0 10}} + + + {{Str2html $commit.Summary}} {{TimeSince $commit.Committer.When $.Lang}}