aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChongyi Zheng <harry@harryzheng.com>2022-12-31 06:46:14 -0500
committerGitHub <noreply@github.com>2022-12-31 19:46:14 +0800
commit443fd27a901aceeda203b602d798792fa0927bb7 (patch)
tree89dcb859437f2f17d9db85aeb566aec73aa31d1a
parent75f128ebf8afb89aecd847a30650c8e7e2aa0214 (diff)
downloadgitea-443fd27a901aceeda203b602d798792fa0927bb7.tar.gz
gitea-443fd27a901aceeda203b602d798792fa0927bb7.zip
Add `sync_on_commit` option for push mirrors api (#22271) (#22292)
Backport of #22271
-rw-r--r--modules/structs/mirror.go2
-rw-r--r--routers/api/v1/repo/mirror.go9
-rw-r--r--templates/swagger/v1_json.tmpl8
3 files changed, 15 insertions, 4 deletions
diff --git a/modules/structs/mirror.go b/modules/structs/mirror.go
index 8e8a8a2705..cb6d567056 100644
--- a/modules/structs/mirror.go
+++ b/modules/structs/mirror.go
@@ -10,6 +10,7 @@ type CreatePushMirrorOption struct {
RemoteUsername string `json:"remote_username"`
RemotePassword string `json:"remote_password"`
Interval string `json:"interval"`
+ SyncOnCommit bool `json:"sync_on_commit"`
}
// PushMirror represents information of a push mirror
@@ -22,4 +23,5 @@ type PushMirror struct {
LastUpdateUnix string `json:"last_update"`
LastError string `json:"last_error"`
Interval string `json:"interval"`
+ SyncOnCommit bool `json:"sync_on_commit"`
}
diff --git a/routers/api/v1/repo/mirror.go b/routers/api/v1/repo/mirror.go
index 91e5e0c031..56bcd07cb5 100644
--- a/routers/api/v1/repo/mirror.go
+++ b/routers/api/v1/repo/mirror.go
@@ -346,10 +346,11 @@ func CreatePushMirror(ctx *context.APIContext, mirrorOption *api.CreatePushMirro
}
pushMirror := &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),
+ Interval: interval,
+ SyncOnCommit: mirrorOption.SyncOnCommit,
}
if err = repo_model.InsertPushMirror(ctx, pushMirror); err != nil {
diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl
index 34dbad6dc4..5df9f2bd2b 100644
--- a/templates/swagger/v1_json.tmpl
+++ b/templates/swagger/v1_json.tmpl
@@ -14831,6 +14831,10 @@
"remote_username": {
"type": "string",
"x-go-name": "RemoteUsername"
+ },
+ "sync_on_commit": {
+ "type": "boolean",
+ "x-go-name": "SyncOnCommit"
}
},
"x-go-package": "code.gitea.io/gitea/modules/structs"
@@ -18011,6 +18015,10 @@
"repo_name": {
"type": "string",
"x-go-name": "RepoName"
+ },
+ "sync_on_commit": {
+ "type": "boolean",
+ "x-go-name": "SyncOnCommit"
}
},
"x-go-package": "code.gitea.io/gitea/modules/structs"