diff options
author | Chongyi Zheng <harryzheng25@gmail.com> | 2022-07-08 15:45:12 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-08 20:45:12 +0100 |
commit | 49f9d43afefd446287b1b2475d7127d405b7a873 (patch) | |
tree | 70f659343c5ed2ce174cb2a5aacb6a66a5084c23 /models/repo/pushmirror.go | |
parent | 496b8e39900842c8253250d3eaddf587be35dfa3 (diff) | |
download | gitea-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 'models/repo/pushmirror.go')
-rw-r--r-- | models/repo/pushmirror.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/models/repo/pushmirror.go b/models/repo/pushmirror.go index 048c0c3487..0a7dea79c9 100644 --- a/models/repo/pushmirror.go +++ b/models/repo/pushmirror.go @@ -23,6 +23,7 @@ type PushMirror struct { Repo *Repository `xorm:"-"` RemoteName string + SyncOnCommit bool `xorm:"NOT NULL DEFAULT true"` Interval time.Duration CreatedUnix timeutil.TimeStamp `xorm:"created"` LastUpdateUnix timeutil.TimeStamp `xorm:"INDEX last_update"` @@ -93,6 +94,14 @@ func GetPushMirrorsByRepoID(repoID int64) ([]*PushMirror, error) { return mirrors, db.GetEngine(db.DefaultContext).Where("repo_id=?", repoID).Find(&mirrors) } +// GetPushMirrorsSyncedOnCommit returns push-mirrors for this repo that should be updated by new commits +func GetPushMirrorsSyncedOnCommit(repoID int64) ([]*PushMirror, error) { + mirrors := make([]*PushMirror, 0, 10) + return mirrors, db.GetEngine(db.DefaultContext). + Where("repo_id=? AND sync_on_commit=?", repoID, true). + Find(&mirrors) +} + // PushMirrorsIterate iterates all push-mirror repositories. func PushMirrorsIterate(limit int, f func(idx int, bean interface{}) error) error { return db.GetEngine(db.DefaultContext). |