Skip to content

Commit 9dcaf14

Browse files
authored
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
1 parent b76970f commit 9dcaf14

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

modules/structs/mirror.go

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type CreatePushMirrorOption struct {
99
RemoteUsername string `json:"remote_username"`
1010
RemotePassword string `json:"remote_password"`
1111
Interval string `json:"interval"`
12+
SyncOnCommit bool `json:"sync_on_commit"`
1213
}
1314

1415
// PushMirror represents information of a push mirror
@@ -21,4 +22,5 @@ type PushMirror struct {
2122
LastUpdateUnix string `json:"last_update"`
2223
LastError string `json:"last_error"`
2324
Interval string `json:"interval"`
25+
SyncOnCommit bool `json:"sync_on_commit"`
2426
}

routers/api/v1/repo/mirror.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,11 @@ func CreatePushMirror(ctx *context.APIContext, mirrorOption *api.CreatePushMirro
345345
}
346346

347347
pushMirror := &repo_model.PushMirror{
348-
RepoID: repo.ID,
349-
Repo: repo,
350-
RemoteName: fmt.Sprintf("remote_mirror_%s", remoteSuffix),
351-
Interval: interval,
348+
RepoID: repo.ID,
349+
Repo: repo,
350+
RemoteName: fmt.Sprintf("remote_mirror_%s", remoteSuffix),
351+
Interval: interval,
352+
SyncOnCommit: mirrorOption.SyncOnCommit,
352353
}
353354

354355
if err = repo_model.InsertPushMirror(ctx, pushMirror); err != nil {

templates/swagger/v1_json.tmpl

+8
Original file line numberDiff line numberDiff line change
@@ -15376,6 +15376,10 @@
1537615376
"remote_username": {
1537715377
"type": "string",
1537815378
"x-go-name": "RemoteUsername"
15379+
},
15380+
"sync_on_commit": {
15381+
"type": "boolean",
15382+
"x-go-name": "SyncOnCommit"
1537915383
}
1538015384
},
1538115385
"x-go-package": "code.gitea.io/gitea/modules/structs"
@@ -18576,6 +18580,10 @@
1857618580
"repo_name": {
1857718581
"type": "string",
1857818582
"x-go-name": "RepoName"
18583+
},
18584+
"sync_on_commit": {
18585+
"type": "boolean",
18586+
"x-go-name": "SyncOnCommit"
1857918587
}
1858018588
},
1858118589
"x-go-package": "code.gitea.io/gitea/modules/structs"

0 commit comments

Comments
 (0)