Skip to content

Commit a383350

Browse files
CirnoTtechknowlogickzeripath
authored andcommitted
Use only first line of commit when creating referenced comment (go-gitea#11960)
* Use only first line of commit when creating referenced comment * Update modules/repofiles/action.go * Display first line only on feeds too Co-authored-by: techknowlogick <[email protected]> Co-authored-by: zeripath <[email protected]>
1 parent e010af1 commit a383350

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

modules/repofiles/action.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"encoding/json"
99
"fmt"
1010
"html"
11+
"strings"
1112

1213
"code.gitea.io/gitea/models"
1314
"code.gitea.io/gitea/modules/git"
@@ -111,7 +112,7 @@ func UpdateIssuesCommit(doer *models.User, repo *models.Repository, commits []*r
111112
continue
112113
}
113114

114-
message := fmt.Sprintf(`<a href="%s/commit/%s">%s</a>`, repo.Link(), c.Sha1, html.EscapeString(c.Message))
115+
message := fmt.Sprintf(`<a href="%s/commit/%s">%s</a>`, repo.Link(), c.Sha1, html.EscapeString(strings.SplitN(c.Message, "\n", 2)[0]))
115116
if err = models.CreateRefComment(doer, refRepo, refIssue, message, c.Sha1); err != nil {
116117
return err
117118
}

templates/user/dashboard/feeds.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
{{ $repoLink := .GetRepoLink}}
8080
{{if $push.Commits}}
8181
{{range $push.Commits}}
82-
<li><img class="img-8" src="{{$push.AvatarLink .AuthorEmail}}"> <a class="commit-id" href="{{$repoLink}}/commit/{{.Sha1}}">{{ShortSha .Sha1}}</a> <span class="text truncate light grey">{{.Message}}</span></li>
82+
{{ $commitLink := printf "%s/commit/%s" $repoLink .Sha1}}
83+
<li><img class="img-8" src="{{$push.AvatarLink .AuthorEmail}}"> <a class="commit-id" href="{{$commitLink}}">{{ShortSha .Sha1}}</a> <span class="text truncate light grey">{{RenderCommitMessage .Message $repoLink $.ComposeMetas}}</span></li>
8384
{{end}}
8485
{{end}}
8586
{{if and (gt $push.Len 1) $push.CompareURL}}<li><a href="{{AppSubUrl}}/{{$push.CompareURL}}">{{$.i18n.Tr "action.compare_commits" $push.Len}} »</a></li>{{end}}

0 commit comments

Comments
 (0)