aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/repo/setting.go
diff options
context:
space:
mode:
authorMohamed Sekour <mohamed.sekour@exfo.com>2022-07-30 18:45:59 +0200
committerGitHub <noreply@github.com>2022-07-30 18:45:59 +0200
commit0e61a74e5a3fc14ff26d1c85065ba336d3f3994b (patch)
tree63282d44a77c410f33595e000d5fef7a9e700a35 /routers/web/repo/setting.go
parente819da083734ddbf30afbc62afd48e9d0e8f3d48 (diff)
downloadgitea-0e61a74e5a3fc14ff26d1c85065ba336d3f3994b.tar.gz
gitea-0e61a74e5a3fc14ff26d1c85065ba336d3f3994b.zip
Add new API endpoints for push mirrors management (#19841)
- Add a new push mirror to specific repository - Sync now ( send all the changes to the configured push mirrors ) - Get list of all push mirrors of a repository - Get a push mirror by ID - Delete push mirror by ID Signed-off-by: Mohamed Sekour <mohamed.sekour@exfo.com> Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'routers/web/repo/setting.go')
-rw-r--r--routers/web/repo/setting.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go
index 7f6b0feafb..a59824cecd 100644
--- a/routers/web/repo/setting.go
+++ b/routers/web/repo/setting.go
@@ -90,7 +90,7 @@ func SettingsCtxData(ctx *context.Context) {
}
ctx.Data["StatsIndexerStatus"] = status
}
- pushMirrors, err := repo_model.GetPushMirrorsByRepoID(ctx.Repo.Repository.ID)
+ pushMirrors, _, err := repo_model.GetPushMirrorsByRepoID(ctx, ctx.Repo.Repository.ID, db.ListOptions{})
if err != nil {
ctx.ServerError("GetPushMirrorsByRepoID", err)
return
@@ -284,7 +284,7 @@ func SettingsPost(ctx *context.Context) {
return
}
- m, err := selectPushMirrorByForm(form, repo)
+ m, err := selectPushMirrorByForm(ctx, form, repo)
if err != nil {
ctx.NotFound("", nil)
return
@@ -305,7 +305,7 @@ func SettingsPost(ctx *context.Context) {
// as an error on the UI for this action
ctx.Data["Err_RepoName"] = nil
- m, err := selectPushMirrorByForm(form, repo)
+ m, err := selectPushMirrorByForm(ctx, form, repo)
if err != nil {
ctx.NotFound("", nil)
return
@@ -316,7 +316,7 @@ func SettingsPost(ctx *context.Context) {
return
}
- if err = repo_model.DeletePushMirrorByID(m.ID); err != nil {
+ if err = repo_model.DeletePushMirrors(ctx, repo_model.PushMirrorOptions{ID: m.ID, RepoID: m.RepoID}); err != nil {
ctx.ServerError("DeletePushMirrorByID", err)
return
}
@@ -364,14 +364,14 @@ func SettingsPost(ctx *context.Context) {
SyncOnCommit: form.PushMirrorSyncOnCommit,
Interval: interval,
}
- if err := repo_model.InsertPushMirror(m); err != nil {
+ if err := repo_model.InsertPushMirror(ctx, m); err != nil {
ctx.ServerError("InsertPushMirror", err)
return
}
if err := mirror_service.AddPushMirrorRemote(ctx, m, address); err != nil {
- if err := repo_model.DeletePushMirrorByID(m.ID); err != nil {
- log.Error("DeletePushMirrorByID %v", err)
+ if err := repo_model.DeletePushMirrors(ctx, repo_model.PushMirrorOptions{ID: m.ID, RepoID: m.RepoID}); err != nil {
+ log.Error("DeletePushMirrors %v", err)
}
ctx.ServerError("AddPushMirrorRemote", err)
return
@@ -1222,13 +1222,13 @@ func SettingsDeleteAvatar(ctx *context.Context) {
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
}
-func selectPushMirrorByForm(form *forms.RepoSettingForm, repo *repo_model.Repository) (*repo_model.PushMirror, error) {
+func selectPushMirrorByForm(ctx *context.Context, form *forms.RepoSettingForm, repo *repo_model.Repository) (*repo_model.PushMirror, error) {
id, err := strconv.ParseInt(form.PushMirrorID, 10, 64)
if err != nil {
return nil, err
}
- pushMirrors, err := repo_model.GetPushMirrorsByRepoID(repo.ID)
+ pushMirrors, _, err := repo_model.GetPushMirrorsByRepoID(ctx, repo.ID, db.ListOptions{})
if err != nil {
return nil, err
}