From 7ff783b7320bdeda89ed6a021c304e64f9d9170e Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 1 Oct 2019 21:40:17 +0800 Subject: Move mirror to a standalone package from models (#7486) * move mirror to a standalone package * fix mirror address in template * fix tests * fix lint * fix comment * fix tests * fix tests * fix vendor * fix fmt * fix lint * remove wrong file submitted * fix conflict * remove unrelated changes * fix go mod * fix tests * clean go mod * make vendor work * make vendor work * fix tests * remove duplicated test --- modules/cron/cron.go | 5 +++-- modules/templates/helper.go | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/cron/cron.go b/modules/cron/cron.go index fe87f86e02..089f0fa767 100644 --- a/modules/cron/cron.go +++ b/modules/cron/cron.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/sync" + mirror_service "code.gitea.io/gitea/services/mirror" "github.com/gogs/cron" ) @@ -51,14 +52,14 @@ func NewContext() { err error ) if setting.Cron.UpdateMirror.Enabled { - entry, err = c.AddFunc("Update mirrors", setting.Cron.UpdateMirror.Schedule, WithUnique(mirrorUpdate, models.MirrorUpdate)) + entry, err = c.AddFunc("Update mirrors", setting.Cron.UpdateMirror.Schedule, WithUnique(mirrorUpdate, mirror_service.Update)) if err != nil { log.Fatal("Cron[Update mirrors]: %v", err) } if setting.Cron.UpdateMirror.RunAtStart { entry.Prev = time.Now() entry.ExecTimes++ - go WithUnique(mirrorUpdate, models.MirrorUpdate)() + go WithUnique(mirrorUpdate, mirror_service.Update)() } } if setting.Cron.RepoHealthCheck.Enabled { diff --git a/modules/templates/helper.go b/modules/templates/helper.go index ba61dd5eef..b40f7117f5 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -28,6 +28,7 @@ import ( "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/services/gitdiff" + mirror_service "code.gitea.io/gitea/services/mirror" "gopkg.in/editorconfig/editorconfig-core-go.v1" ) @@ -233,6 +234,8 @@ func NewFuncMap() []template.FuncMap { return float32(n) * 100 / float32(sum) }, "CommentMustAsDiff": gitdiff.CommentMustAsDiff, + "MirrorAddress": mirror_service.Address, + "MirrorFullAddress": mirror_service.AddressNoCredentials, }} } -- cgit v1.2.3