summaryrefslogtreecommitdiffstats
path: root/services/mirror
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-09-06 02:37:47 +0800
committerGitHub <noreply@github.com>2023-09-05 18:37:47 +0000
commit540bf9fa6d0d86297c9d575640798b718767bd9f (patch)
tree4b4a782b71e6f066af6c7807337745dc5ee6899a /services/mirror
parent084eacb5d42f1ed2520442a4bbc91bb70c9759e1 (diff)
downloadgitea-540bf9fa6d0d86297c9d575640798b718767bd9f.tar.gz
gitea-540bf9fa6d0d86297c9d575640798b718767bd9f.zip
Move notification interface to services layer (#26915)
Extract from #22266
Diffstat (limited to 'services/mirror')
-rw-r--r--services/mirror/mirror_pull.go10
-rw-r--r--services/mirror/notifier.go13
2 files changed, 11 insertions, 12 deletions
diff --git a/services/mirror/mirror_pull.go b/services/mirror/mirror_pull.go
index 51c7de58b6..321bd38fc3 100644
--- a/services/mirror/mirror_pull.go
+++ b/services/mirror/mirror_pull.go
@@ -16,13 +16,13 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/lfs"
"code.gitea.io/gitea/modules/log"
- "code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/process"
"code.gitea.io/gitea/modules/proxy"
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
+ notify_service "code.gitea.io/gitea/services/notify"
)
// gitShortEmptySha Git short empty SHA
@@ -479,18 +479,18 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
log.Error("SyncMirrors [repo: %-v]: unable to GetRefCommitID [ref_name: %s]: %v", m.Repo, result.refName, err)
continue
}
- notification.NotifySyncPushCommits(ctx, m.Repo.MustOwner(ctx), m.Repo, &repo_module.PushUpdateOptions{
+ notify_service.SyncPushCommits(ctx, m.Repo.MustOwner(ctx), m.Repo, &repo_module.PushUpdateOptions{
RefFullName: result.refName,
OldCommitID: git.EmptySHA,
NewCommitID: commitID,
}, repo_module.NewPushCommits())
- notification.NotifySyncCreateRef(ctx, m.Repo.MustOwner(ctx), m.Repo, result.refName, commitID)
+ notify_service.SyncCreateRef(ctx, m.Repo.MustOwner(ctx), m.Repo, result.refName, commitID)
continue
}
// Delete reference
if result.newCommitID == gitShortEmptySha {
- notification.NotifySyncDeleteRef(ctx, m.Repo.MustOwner(ctx), m.Repo, result.refName)
+ notify_service.SyncDeleteRef(ctx, m.Repo.MustOwner(ctx), m.Repo, result.refName)
continue
}
@@ -525,7 +525,7 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
theCommits.CompareURL = m.Repo.ComposeCompareURL(oldCommitID, newCommitID)
- notification.NotifySyncPushCommits(ctx, m.Repo.MustOwner(ctx), m.Repo, &repo_module.PushUpdateOptions{
+ notify_service.SyncPushCommits(ctx, m.Repo.MustOwner(ctx), m.Repo, &repo_module.PushUpdateOptions{
RefFullName: result.refName,
OldCommitID: oldCommitID,
NewCommitID: newCommitID,
diff --git a/services/mirror/notifier.go b/services/mirror/notifier.go
index e0e1b443e0..93d904470d 100644
--- a/services/mirror/notifier.go
+++ b/services/mirror/notifier.go
@@ -8,25 +8,24 @@ import (
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
- "code.gitea.io/gitea/modules/notification"
- "code.gitea.io/gitea/modules/notification/base"
"code.gitea.io/gitea/modules/repository"
+ notify_service "code.gitea.io/gitea/services/notify"
)
func init() {
- notification.RegisterNotifier(&mirrorNotifier{})
+ notify_service.RegisterNotifier(&mirrorNotifier{})
}
type mirrorNotifier struct {
- base.NullNotifier
+ notify_service.NullNotifier
}
-var _ base.Notifier = &mirrorNotifier{}
+var _ notify_service.Notifier = &mirrorNotifier{}
-func (m *mirrorNotifier) NotifyPushCommits(ctx context.Context, _ *user_model.User, repo *repo_model.Repository, _ *repository.PushUpdateOptions, _ *repository.PushCommits) {
+func (m *mirrorNotifier) PushCommits(ctx context.Context, _ *user_model.User, repo *repo_model.Repository, _ *repository.PushUpdateOptions, _ *repository.PushCommits) {
syncPushMirrorWithSyncOnCommit(ctx, repo.ID)
}
-func (m *mirrorNotifier) NotifySyncPushCommits(ctx context.Context, _ *user_model.User, repo *repo_model.Repository, _ *repository.PushUpdateOptions, _ *repository.PushCommits) {
+func (m *mirrorNotifier) SyncPushCommits(ctx context.Context, _ *user_model.User, repo *repo_model.Repository, _ *repository.PushUpdateOptions, _ *repository.PushCommits) {
syncPushMirrorWithSyncOnCommit(ctx, repo.ID)
}