aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/repo/setting.go
diff options
context:
space:
mode:
authorChongyi Zheng <harryzheng25@gmail.com>2022-07-08 15:45:12 -0400
committerGitHub <noreply@github.com>2022-07-08 20:45:12 +0100
commit49f9d43afefd446287b1b2475d7127d405b7a873 (patch)
tree70f659343c5ed2ce174cb2a5aacb6a66a5084c23 /routers/web/repo/setting.go
parent496b8e39900842c8253250d3eaddf587be35dfa3 (diff)
downloadgitea-49f9d43afefd446287b1b2475d7127d405b7a873.tar.gz
gitea-49f9d43afefd446287b1b2475d7127d405b7a873.zip
Implement sync push mirror on commit (#19411)
Support synchronizing with the push mirrors whenever new commits are pushed or synced from pull mirror. Related Issues: #18220 Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'routers/web/repo/setting.go')
-rw-r--r--routers/web/repo/setting.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go
index fae62c1020..5ded0561c6 100644
--- a/routers/web/repo/setting.go
+++ b/routers/web/repo/setting.go
@@ -29,6 +29,7 @@ import (
"code.gitea.io/gitea/modules/indexer/stats"
"code.gitea.io/gitea/modules/lfs"
"code.gitea.io/gitea/modules/log"
+ mirror_module "code.gitea.io/gitea/modules/mirror"
"code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/structs"
@@ -272,7 +273,7 @@ func SettingsPost(ctx *context.Context) {
return
}
- mirror_service.StartToMirror(repo.ID)
+ mirror_module.AddPullMirrorToQueue(repo.ID)
ctx.Flash.Info(ctx.Tr("repo.settings.mirror_sync_in_progress"))
ctx.Redirect(repo.Link() + "/settings")
@@ -289,7 +290,7 @@ func SettingsPost(ctx *context.Context) {
return
}
- mirror_service.AddPushMirrorToQueue(m.ID)
+ mirror_module.AddPushMirrorToQueue(m.ID)
ctx.Flash.Info(ctx.Tr("repo.settings.mirror_sync_in_progress"))
ctx.Redirect(repo.Link() + "/settings")
@@ -357,10 +358,11 @@ func SettingsPost(ctx *context.Context) {
}
m := &repo_model.PushMirror{
- RepoID: repo.ID,
- Repo: repo,
- RemoteName: fmt.Sprintf("remote_mirror_%s", remoteSuffix),
- Interval: interval,
+ RepoID: repo.ID,
+ Repo: repo,
+ RemoteName: fmt.Sprintf("remote_mirror_%s", remoteSuffix),
+ SyncOnCommit: form.PushMirrorSyncOnCommit,
+ Interval: interval,
}
if err := repo_model.InsertPushMirror(m); err != nil {
ctx.ServerError("InsertPushMirror", err)