Skip to content

Commit

Permalink
Add sync_on_commit option for push mirrors api (#22271) (#22292)
Browse files Browse the repository at this point in the history
Backport of #22271
  • Loading branch information
harryzcy authored Dec 31, 2022
1 parent 75f128e commit 443fd27
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions modules/structs/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"`
}
9 changes: 5 additions & 4 deletions routers/api/v1/repo/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions templates/swagger/v1_json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 443fd27

Please sign in to comment.