Merge pull request #712 from Dennis-Smurf/enhancement-issuelink-in-commit
Added issue link rendering in commit messages
This commit is contained in:
commit
3fd41d138c
|
@ -5,12 +5,14 @@
|
||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"container/list"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/Unknwon/com"
|
"github.com/Unknwon/com"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
|
"github.com/gogits/gogs/modules/git"
|
||||||
"github.com/gogits/gogs/modules/middleware"
|
"github.com/gogits/gogs/modules/middleware"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
@ -72,6 +74,7 @@ func Commits(ctx *middleware.Context) {
|
||||||
ctx.Handle(500, "CommitsByRange", err)
|
ctx.Handle(500, "CommitsByRange", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
commits = RenderIssueLinks(commits, ctx.Repo.RepoLink)
|
||||||
commits = models.ValidateCommitsWithEmails(commits)
|
commits = models.ValidateCommitsWithEmails(commits)
|
||||||
|
|
||||||
ctx.Data["Commits"] = commits
|
ctx.Data["Commits"] = commits
|
||||||
|
@ -83,6 +86,16 @@ func Commits(ctx *middleware.Context) {
|
||||||
ctx.HTML(200, COMMITS)
|
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) {
|
func SearchCommits(ctx *middleware.Context) {
|
||||||
ctx.Data["IsSearchPage"] = true
|
ctx.Data["IsSearchPage"] = true
|
||||||
ctx.Data["IsRepoToolbarCommits"] = true
|
ctx.Data["IsRepoToolbarCommits"] = true
|
||||||
|
@ -110,6 +123,7 @@ func SearchCommits(ctx *middleware.Context) {
|
||||||
ctx.Handle(500, "SearchCommits", err)
|
ctx.Handle(500, "SearchCommits", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
commits = RenderIssueLinks(commits, ctx.Repo.RepoLink)
|
||||||
commits = models.ValidateCommitsWithEmails(commits)
|
commits = models.ValidateCommitsWithEmails(commits)
|
||||||
|
|
||||||
ctx.Data["Keyword"] = keyword
|
ctx.Data["Keyword"] = keyword
|
||||||
|
@ -171,6 +185,7 @@ func FileHistory(ctx *middleware.Context) {
|
||||||
ctx.Handle(500, "repo.FileHistory(CommitsByRange)", err)
|
ctx.Handle(500, "repo.FileHistory(CommitsByRange)", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
commits = RenderIssueLinks(commits, ctx.Repo.RepoLink)
|
||||||
commits = models.ValidateCommitsWithEmails(commits)
|
commits = models.ValidateCommitsWithEmails(commits)
|
||||||
|
|
||||||
ctx.Data["Commits"] = commits
|
ctx.Data["Commits"] = commits
|
||||||
|
@ -191,7 +206,7 @@ func Diff(ctx *middleware.Context) {
|
||||||
commitId := ctx.Repo.CommitId
|
commitId := ctx.Repo.CommitId
|
||||||
|
|
||||||
commit := ctx.Repo.Commit
|
commit := ctx.Repo.Commit
|
||||||
|
commit.CommitMessage = string(base.RenderissueIndexPattern([]byte(commit.CommitMessage), ctx.Repo.RepoLink))
|
||||||
diff, err := models.GetDiffCommit(models.RepoPath(userName, repoName),
|
diff, err := models.GetDiffCommit(models.RepoPath(userName, repoName),
|
||||||
commitId, setting.MaxGitDiffLines)
|
commitId, setting.MaxGitDiffLines)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -199,6 +199,7 @@ func Home(ctx *middleware.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
lastCommit := ctx.Repo.Commit
|
lastCommit := ctx.Repo.Commit
|
||||||
|
lastCommit.CommitMessage = string(base.RenderissueIndexPattern([]byte(lastCommit.CommitMessage), ctx.Repo.RepoLink))
|
||||||
if len(treePath) > 0 {
|
if len(treePath) > 0 {
|
||||||
c, err := ctx.Repo.Commit.GetCommitOfRelPath(treePath)
|
c, err := ctx.Repo.Commit.GetCommitOfRelPath(treePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
</td>
|
</td>
|
||||||
<td class="sha"><a rel="nofollow" class="label label-green" href="{{AppSubUrl}}/{{$username}}/{{$reponame}}/commit/{{.Id}} ">{{SubStr .Id.String 0 10}} </a></td>
|
<td class="sha"><a rel="nofollow" class="label label-green" href="{{AppSubUrl}}/{{$username}}/{{$reponame}}/commit/{{.Id}} ">{{SubStr .Id.String 0 10}} </a></td>
|
||||||
<td class="message"><span class="text-truncate">{{.Summary}}</span></td>
|
<td class="message"><span class="text-truncate">{{Str2html .Summary}}</span></td>
|
||||||
<td class="date">{{TimeSince .Author.When $.Lang}}</td>
|
<td class="date">{{TimeSince .Author.When $.Lang}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<div class="panel panel-info panel-radius diff-head-box">
|
<div class="panel panel-info panel-radius diff-head-box">
|
||||||
<div class="panel-header">
|
<div class="panel-header">
|
||||||
<a class="pull-right btn btn-blue btn-header btn-medium btn-radius" rel="nofollow" href="{{.SourcePath}}">{{.i18n.Tr "repo.diff.browse_source"}}</a>
|
<a class="pull-right btn btn-blue btn-header btn-medium btn-radius" rel="nofollow" href="{{.SourcePath}}">{{.i18n.Tr "repo.diff.browse_source"}}</a>
|
||||||
<h4 class="commit-message">{{.Commit.Message}}</h4>
|
<h4 class="commit-message">{{Str2html .Commit.Message}}</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<span class="pull-right">
|
<span class="pull-right">
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
</span>
|
</span>
|
||||||
<span class="last-commit"><a href="{{.RepoLink}}/commit/{{.LastCommit.Id}}" rel="nofollow">
|
<span class="last-commit"><a href="{{.RepoLink}}/commit/{{.LastCommit.Id}}" rel="nofollow">
|
||||||
<strong>{{ShortSha .LastCommit.Id.String}}</strong></a>
|
<strong>{{ShortSha .LastCommit.Id.String}}</strong></a>
|
||||||
<span class="text-truncate">{{.LastCommit.Summary}}</span>
|
<span class="text-truncate">{{Str2html .LastCommit.Summary}}</span>
|
||||||
</span>
|
</span>
|
||||||
<span class="age right">{{TimeSince .LastCommit.Author.When $.Lang}}</span>
|
<span class="age right">{{TimeSince .LastCommit.Author.When $.Lang}}</span>
|
||||||
</th>
|
</th>
|
||||||
|
@ -25,6 +25,7 @@
|
||||||
<tr class="has-parent">
|
<tr class="has-parent">
|
||||||
<td class="icon"></td>
|
<td class="icon"></td>
|
||||||
<td class="name"><a href="{{EscapePound .BranchLink}}{{.ParentPath}}">..</a></td>
|
<td class="name"><a href="{{EscapePound .BranchLink}}{{.ParentPath}}">..</a></td>
|
||||||
|
<th class="sha">SHA1</th>
|
||||||
<td class="msg"></td>
|
<td class="msg"></td>
|
||||||
<td class="age"></td>
|
<td class="age"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -48,8 +49,11 @@
|
||||||
<a href="{{EscapePound $.BranchLink}}/{{$.TreePath}}{{$entry.Name}}" class="text-truncate">{{$entry.Name}}</a>
|
<a href="{{EscapePound $.BranchLink}}/{{$.TreePath}}{{$entry.Name}}" class="text-truncate">{{$entry.Name}}</a>
|
||||||
</td>
|
</td>
|
||||||
{{end}}
|
{{end}}
|
||||||
<td class="msg">
|
<td class="sha">
|
||||||
<a class="text-truncate" href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{$commit.Id}}" rel="nofollow">{{$commit.Summary}}</a>
|
<a rel="nofollow" class="label label-green" href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{$commit.Id}} ">{{SubStr $commit.Id.String 0 10}} </a>
|
||||||
|
</td>
|
||||||
|
<td class="message">
|
||||||
|
<span class="text-truncate">{{Str2html $commit.Summary}}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="age">{{TimeSince $commit.Committer.When $.Lang}}</td>
|
<td class="age">{{TimeSince $commit.Committer.When $.Lang}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Reference in New Issue