Skip to content

Commit 443fd27

Browse files
authored
Add sync_on_commit option for push mirrors api (#22271) (#22292)
Backport of #22271
1 parent 75f128e commit 443fd27

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
@@ -10,6 +10,7 @@ type CreatePushMirrorOption struct {
1010
RemoteUsername string `json:"remote_username"`
1111
RemotePassword string `json:"remote_password"`
1212
Interval string `json:"interval"`
13+
SyncOnCommit bool `json:"sync_on_commit"`
1314
}
1415

1516
// PushMirror represents information of a push mirror
@@ -22,4 +23,5 @@ type PushMirror struct {
2223
LastUpdateUnix string `json:"last_update"`
2324
LastError string `json:"last_error"`
2425
Interval string `json:"interval"`
26+
SyncOnCommit bool `json:"sync_on_commit"`
2527
}

routers/api/v1/repo/mirror.go

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

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

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

templates/swagger/v1_json.tmpl

+8
Original file line numberDiff line numberDiff line change
@@ -14831,6 +14831,10 @@
1483114831
"remote_username": {
1483214832
"type": "string",
1483314833
"x-go-name": "RemoteUsername"
14834+
},
14835+
"sync_on_commit": {
14836+
"type": "boolean",
14837+
"x-go-name": "SyncOnCommit"
1483414838
}
1483514839
},
1483614840
"x-go-package": "code.gitea.io/gitea/modules/structs"
@@ -18011,6 +18015,10 @@
1801118015
"repo_name": {
1801218016
"type": "string",
1801318017
"x-go-name": "RepoName"
18018+
},
18019+
"sync_on_commit": {
18020+
"type": "boolean",
18021+
"x-go-name": "SyncOnCommit"
1801418022
}
1801518023
},
1801618024
"x-go-package": "code.gitea.io/gitea/modules/structs"

0 commit comments

Comments
 (0)