aboutsummaryrefslogtreecommitdiffstats
path: root/services/webhook/dingtalk.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-10-16 18:22:34 +0200
committerGitHub <noreply@github.com>2022-10-17 00:22:34 +0800
commitcad9adeff41595ea32281dbc2918e653c3e3a839 (patch)
treea62bf796f12655c85323ded8922c6ea1d5e256ed /services/webhook/dingtalk.go
parent6f48a36227b7427afd2020aa416afe49d4c81015 (diff)
downloadgitea-cad9adeff41595ea32281dbc2918e653c3e3a839.tar.gz
gitea-cad9adeff41595ea32281dbc2918e653c3e3a839.zip
Display total commit count in hook message (#21400)
Fixes #21379 The commits are capped by `setting.UI.FeedMaxCommitNum` so `len(commits)` is not the correct number. So this PR adds a new `TotalCommits` field. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'services/webhook/dingtalk.go')
-rw-r--r--services/webhook/dingtalk.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/services/webhook/dingtalk.go b/services/webhook/dingtalk.go
index 5112bdb347..e047e994c2 100644
--- a/services/webhook/dingtalk.go
+++ b/services/webhook/dingtalk.go
@@ -67,14 +67,14 @@ func (d *DingtalkPayload) Push(p *api.PushPayload) (api.Payloader, error) {
)
var titleLink, linkText string
- if len(p.Commits) == 1 {
+ if p.TotalCommits == 1 {
commitDesc = "1 new commit"
titleLink = p.Commits[0].URL
- linkText = fmt.Sprintf("view commit %s", p.Commits[0].ID[:7])
+ linkText = "view commit"
} else {
- commitDesc = fmt.Sprintf("%d new commits", len(p.Commits))
+ commitDesc = fmt.Sprintf("%d new commits", p.TotalCommits)
titleLink = p.CompareURL
- linkText = fmt.Sprintf("view commit %s...%s", p.Commits[0].ID[:7], p.Commits[len(p.Commits)-1].ID[:7])
+ linkText = "view commits"
}
if titleLink == "" {
titleLink = p.Repo.HTMLURL + "/src/" + util.PathEscapeSegments(branchName)