mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-25 11:22:16 +00:00
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>
This commit is contained in:
parent
496b8e3990
commit
49f9d43afe
12 changed files with 208 additions and 98 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue