From 8b31bff9e6a38f044b22382d3e9ea848b3359647 Mon Sep 17 00:00:00 2001 From: harryzcy Date: Thu, 29 Dec 2022 20:48:27 -0500 Subject: [PATCH 1/3] Add `sync_on_commit` option for push mirrors api --- modules/structs/mirror.go | 2 ++ routers/api/v1/repo/mirror.go | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/structs/mirror.go b/modules/structs/mirror.go index 21e7751f765e5..55cd133a4fc7b 100644 --- a/modules/structs/mirror.go +++ b/modules/structs/mirror.go @@ -9,6 +9,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 @@ -21,4 +22,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 5fce5a4a803f9..06bfabe3d2d29 100644 --- a/routers/api/v1/repo/mirror.go +++ b/routers/api/v1/repo/mirror.go @@ -345,10 +345,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 { From 9ad05ccef6ec3084e67b492cb4fabbd0343c729e Mon Sep 17 00:00:00 2001 From: harryzcy Date: Thu, 29 Dec 2022 20:59:44 -0500 Subject: [PATCH 2/3] Re-generate swagger --- templates/swagger/v1_json.tmpl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index c86c6744deec2..fc4652f0b4e81 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -15376,6 +15376,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" @@ -18576,6 +18580,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" @@ -20780,4 +20788,4 @@ "TOTPHeader": [] } ] -} +} \ No newline at end of file From 758bc0d2da0e5ffac549b8353c6c5a177c10eec6 Mon Sep 17 00:00:00 2001 From: harryzcy Date: Thu, 29 Dec 2022 21:05:36 -0500 Subject: [PATCH 3/3] Fix new line issue for swagger --- templates/swagger/v1_json.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index fc4652f0b4e81..c2232825966d3 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -20788,4 +20788,4 @@ "TOTPHeader": [] } ] -} \ No newline at end of file +}