Don't run push mirrors for archived repos (#27140)
Fixes https://codeberg.org/forgejo/forgejo/issues/612 At the moment push mirrors are still run if a repo is archived. This PR fixes this.
This commit is contained in:
parent
1af45689f9
commit
f3ba3e922d
5 changed files with 191 additions and 181 deletions
|
@ -1181,13 +1181,13 @@ func Routes() *web.Route {
|
|||
Delete(reqToken(), reqRepoWriter(unit.TypeReleases), repo.DeleteReleaseByTag)
|
||||
})
|
||||
}, reqRepoReader(unit.TypeReleases))
|
||||
m.Post("/mirror-sync", reqToken(), reqRepoWriter(unit.TypeCode), repo.MirrorSync)
|
||||
m.Post("/push_mirrors-sync", reqAdmin(), reqToken(), repo.PushMirrorSync)
|
||||
m.Post("/mirror-sync", reqToken(), reqRepoWriter(unit.TypeCode), mustNotBeArchived, repo.MirrorSync)
|
||||
m.Post("/push_mirrors-sync", reqAdmin(), reqToken(), mustNotBeArchived, repo.PushMirrorSync)
|
||||
m.Group("/push_mirrors", func() {
|
||||
m.Combo("").Get(repo.ListPushMirrors).
|
||||
Post(bind(api.CreatePushMirrorOption{}), repo.AddPushMirror)
|
||||
Post(mustNotBeArchived, bind(api.CreatePushMirrorOption{}), repo.AddPushMirror)
|
||||
m.Combo("/{name}").
|
||||
Delete(repo.DeletePushMirrorByRemoteName).
|
||||
Delete(mustNotBeArchived, repo.DeletePushMirrorByRemoteName).
|
||||
Get(repo.GetPushMirrorByName)
|
||||
}, reqAdmin(), reqToken())
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
ctx.Redirect(repo.Link() + "/settings")
|
||||
|
||||
case "mirror":
|
||||
if !setting.Mirror.Enabled || !repo.IsMirror {
|
||||
if !setting.Mirror.Enabled || !repo.IsMirror || repo.IsArchived {
|
||||
ctx.NotFound("", nil)
|
||||
return
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
ctx.Redirect(repo.Link() + "/settings")
|
||||
|
||||
case "mirror-sync":
|
||||
if !setting.Mirror.Enabled || !repo.IsMirror {
|
||||
if !setting.Mirror.Enabled || !repo.IsMirror || repo.IsArchived {
|
||||
ctx.NotFound("", nil)
|
||||
return
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
ctx.Redirect(repo.Link() + "/settings")
|
||||
|
||||
case "push-mirror-update":
|
||||
if !setting.Mirror.Enabled {
|
||||
if !setting.Mirror.Enabled || repo.IsArchived {
|
||||
ctx.NotFound("", nil)
|
||||
return
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
ctx.Redirect(repo.Link() + "/settings")
|
||||
|
||||
case "push-mirror-remove":
|
||||
if !setting.Mirror.Enabled {
|
||||
if !setting.Mirror.Enabled || repo.IsArchived {
|
||||
ctx.NotFound("", nil)
|
||||
return
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
ctx.Redirect(repo.Link() + "/settings")
|
||||
|
||||
case "push-mirror-add":
|
||||
if setting.Mirror.DisableNewPush {
|
||||
if setting.Mirror.DisableNewPush || repo.IsArchived {
|
||||
ctx.NotFound("", nil)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue