From 92a05f87f070b0d2a1e9eb53072e00f0f1c3b69a Mon Sep 17 00:00:00 2001 From: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com> Date: Fri, 19 Jun 2020 09:19:56 +0200 Subject: [PATCH] Use only first line of commit when creating referenced comment (#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 Co-authored-by: zeripath --- modules/repofiles/action.go | 3 ++- templates/user/dashboard/feeds.tmpl | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/repofiles/action.go b/modules/repofiles/action.go index 44ca285ef0..464249d19b 100644 --- a/modules/repofiles/action.go +++ b/modules/repofiles/action.go @@ -8,6 +8,7 @@ import ( "encoding/json" "fmt" "html" + "strings" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/git" @@ -111,7 +112,7 @@ func UpdateIssuesCommit(doer *models.User, repo *models.Repository, commits []*r continue } - message := fmt.Sprintf(`%s`, repo.Link(), c.Sha1, html.EscapeString(c.Message)) + message := fmt.Sprintf(`%s`, repo.Link(), c.Sha1, html.EscapeString(strings.SplitN(c.Message, "\n", 2)[0])) if err = models.CreateRefComment(doer, refRepo, refIssue, message, c.Sha1); err != nil { return err } diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl index a1b4218dc4..a67fe54849 100644 --- a/templates/user/dashboard/feeds.tmpl +++ b/templates/user/dashboard/feeds.tmpl @@ -79,7 +79,8 @@ {{ $repoLink := .GetRepoLink}} {{if $push.Commits}} {{range $push.Commits}} -
  • {{ShortSha .Sha1}} {{.Message}}
  • + {{ $commitLink := printf "%s/commit/%s" $repoLink .Sha1}} +
  • {{ShortSha .Sha1}} {{RenderCommitMessage .Message $repoLink $.ComposeMetas}}
  • {{end}} {{end}} {{if and (gt $push.Len 1) $push.CompareURL}}
  • {{$.i18n.Tr "action.compare_commits" $push.Len}} ยป
  • {{end}}