summaryrefslogtreecommitdiffstats
path: root/modules/notification
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 /modules/notification
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 'modules/notification')
-rw-r--r--modules/notification/webhook/webhook.go38
1 files changed, 20 insertions, 18 deletions
diff --git a/modules/notification/webhook/webhook.go b/modules/notification/webhook/webhook.go
index 0eb2099a20..b93e90368a 100644
--- a/modules/notification/webhook/webhook.go
+++ b/modules/notification/webhook/webhook.go
@@ -645,15 +645,16 @@ func (m *webhookNotifier) NotifyPushCommits(pusher *user_model.User, repo *repo_
}
if err := webhook_services.PrepareWebhooks(repo, webhook.HookEventPush, &api.PushPayload{
- Ref: opts.RefFullName,
- Before: opts.OldCommitID,
- After: opts.NewCommitID,
- CompareURL: setting.AppURL + commits.CompareURL,
- Commits: apiCommits,
- HeadCommit: apiHeadCommit,
- Repo: convert.ToRepo(repo, perm.AccessModeOwner),
- Pusher: apiPusher,
- Sender: apiPusher,
+ Ref: opts.RefFullName,
+ Before: opts.OldCommitID,
+ After: opts.NewCommitID,
+ CompareURL: setting.AppURL + commits.CompareURL,
+ Commits: apiCommits,
+ TotalCommits: commits.Len,
+ HeadCommit: apiHeadCommit,
+ Repo: convert.ToRepo(repo, perm.AccessModeOwner),
+ Pusher: apiPusher,
+ Sender: apiPusher,
}); err != nil {
log.Error("PrepareWebhooks: %v", err)
}
@@ -875,15 +876,16 @@ func (m *webhookNotifier) NotifySyncPushCommits(pusher *user_model.User, repo *r
}
if err := webhook_services.PrepareWebhooks(repo, webhook.HookEventPush, &api.PushPayload{
- Ref: opts.RefFullName,
- Before: opts.OldCommitID,
- After: opts.NewCommitID,
- CompareURL: setting.AppURL + commits.CompareURL,
- Commits: apiCommits,
- HeadCommit: apiHeadCommit,
- Repo: convert.ToRepo(repo, perm.AccessModeOwner),
- Pusher: apiPusher,
- Sender: apiPusher,
+ Ref: opts.RefFullName,
+ Before: opts.OldCommitID,
+ After: opts.NewCommitID,
+ CompareURL: setting.AppURL + commits.CompareURL,
+ Commits: apiCommits,
+ TotalCommits: commits.Len,
+ HeadCommit: apiHeadCommit,
+ Repo: convert.ToRepo(repo, perm.AccessModeOwner),
+ Pusher: apiPusher,
+ Sender: apiPusher,
}); err != nil {
log.Error("PrepareWebhooks: %v", err)
}