Переглянути джерело

Add `sync_on_commit` option for push mirrors api (#22271)

Push mirrors `sync_on_commit` option was added to the web interface in
v1.18.0. However, it's not added to the API. This PR updates the API
endpoint.

Fixes #22267

Also, I think this should be backported to 1.18
tags/v1.19.0-rc0
Chongyi Zheng 1 рік тому
джерело
коміт
9dcaf14a14
Аккаунт користувача з таким Email не знайдено

+ 2
- 0
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"`
}

+ 5
- 4
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 {

+ 8
- 0
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"

Завантаження…
Відмінити
Зберегти