diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-11-24 13:16:59 +0800 |
---|---|---|
committer | techknowlogick <techknowlogick@gitea.io> | 2019-11-24 00:16:59 -0500 |
commit | 8ab35eefc4ff5db3f2f0a62f6f0272eae9be0585 (patch) | |
tree | 5249bcee68fb96652adc8f7dd46b604cbf15cd5e /modules/notification/webhook | |
parent | e3f22ad2cca094cba057683f35f8536e3f71a582 (diff) | |
download | gitea-8ab35eefc4ff5db3f2f0a62f6f0272eae9be0585.tar.gz gitea-8ab35eefc4ff5db3f2f0a62f6f0272eae9be0585.zip |
Move mirror sync actions to notification (#9022)
* Move mirror sync actions to notification
* fix lint
Diffstat (limited to 'modules/notification/webhook')
-rw-r--r-- | modules/notification/webhook/webhook.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/modules/notification/webhook/webhook.go b/modules/notification/webhook/webhook.go index 213e33c096..4ef60fef84 100644 --- a/modules/notification/webhook/webhook.go +++ b/modules/notification/webhook/webhook.go @@ -695,3 +695,25 @@ func (m *webhookNotifier) NotifyUpdateRelease(doer *models.User, rel *models.Rel func (m *webhookNotifier) NotifyDeleteRelease(doer *models.User, rel *models.Release) { sendReleaseHook(doer, rel, api.HookReleaseDeleted) } + +func (m *webhookNotifier) NotifySyncPushCommits(pusher *models.User, repo *models.Repository, refName, oldCommitID, newCommitID string, commits *models.PushCommits) { + apiPusher := pusher.APIFormat() + apiCommits, err := commits.ToAPIPayloadCommits(repo.RepoPath(), repo.HTMLURL()) + if err != nil { + log.Error("commits.ToAPIPayloadCommits failed: %v", err) + return + } + + if err := webhook_module.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{ + Ref: refName, + Before: oldCommitID, + After: newCommitID, + CompareURL: setting.AppURL + commits.CompareURL, + Commits: apiCommits, + Repo: repo.APIFormat(models.AccessModeOwner), + Pusher: apiPusher, + Sender: apiPusher, + }); err != nil { + log.Error("PrepareWebhooks: %v", err) + } +} |