mirror of
https://github.com/go-gitea/gitea
synced 2024-12-23 00:54:28 +00:00
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
@ -121,8 +121,11 @@ func GetPushMirrorsSyncedOnCommit(ctx context.Context, repoID int64) ([]*PushMir
|
|||||||
// PushMirrorsIterate iterates all push-mirror repositories.
|
// PushMirrorsIterate iterates all push-mirror repositories.
|
||||||
func PushMirrorsIterate(ctx context.Context, limit int, f func(idx int, bean any) error) error {
|
func PushMirrorsIterate(ctx context.Context, limit int, f func(idx int, bean any) error) error {
|
||||||
sess := db.GetEngine(ctx).
|
sess := db.GetEngine(ctx).
|
||||||
Where("last_update + (`interval` / ?) <= ?", time.Second, time.Now().Unix()).
|
Table("push_mirror").
|
||||||
And("`interval` != 0").
|
Join("INNER", "`repository`", "`repository`.id = `push_mirror`.repo_id").
|
||||||
|
Where("`push_mirror`.last_update + (`push_mirror`.`interval` / ?) <= ?", time.Second, time.Now().Unix()).
|
||||||
|
And("`push_mirror`.`interval` != 0").
|
||||||
|
And("`repository`.is_archived = ?", false).
|
||||||
OrderBy("last_update ASC")
|
OrderBy("last_update ASC")
|
||||||
if limit > 0 {
|
if limit > 0 {
|
||||||
sess = sess.Limit(limit)
|
sess = sess.Limit(limit)
|
||||||
|
@ -2377,6 +2377,7 @@ settings.archive.error = An error occurred while trying to archive the repo. See
|
|||||||
settings.archive.error_ismirror = You cannot archive a mirrored repo.
|
settings.archive.error_ismirror = You cannot archive a mirrored repo.
|
||||||
settings.archive.branchsettings_unavailable = Branch settings are not available if the repo is archived.
|
settings.archive.branchsettings_unavailable = Branch settings are not available if the repo is archived.
|
||||||
settings.archive.tagsettings_unavailable = Tag settings are not available if the repo is archived.
|
settings.archive.tagsettings_unavailable = Tag settings are not available if the repo is archived.
|
||||||
|
settings.archive.mirrors_unavailable = Mirrors are not available if the repo is archived.
|
||||||
settings.unarchive.button = Unarchive repo
|
settings.unarchive.button = Unarchive repo
|
||||||
settings.unarchive.header = Unarchive this repo
|
settings.unarchive.header = Unarchive this repo
|
||||||
settings.unarchive.text = Unarchiving the repo will restore its ability to receive commits and pushes, as well as new issues and pull-requests.
|
settings.unarchive.text = Unarchiving the repo will restore its ability to receive commits and pushes, as well as new issues and pull-requests.
|
||||||
|
@ -1181,13 +1181,13 @@ func Routes() *web.Route {
|
|||||||
Delete(reqToken(), reqRepoWriter(unit.TypeReleases), repo.DeleteReleaseByTag)
|
Delete(reqToken(), reqRepoWriter(unit.TypeReleases), repo.DeleteReleaseByTag)
|
||||||
})
|
})
|
||||||
}, reqRepoReader(unit.TypeReleases))
|
}, reqRepoReader(unit.TypeReleases))
|
||||||
m.Post("/mirror-sync", reqToken(), reqRepoWriter(unit.TypeCode), repo.MirrorSync)
|
m.Post("/mirror-sync", reqToken(), reqRepoWriter(unit.TypeCode), mustNotBeArchived, repo.MirrorSync)
|
||||||
m.Post("/push_mirrors-sync", reqAdmin(), reqToken(), repo.PushMirrorSync)
|
m.Post("/push_mirrors-sync", reqAdmin(), reqToken(), mustNotBeArchived, repo.PushMirrorSync)
|
||||||
m.Group("/push_mirrors", func() {
|
m.Group("/push_mirrors", func() {
|
||||||
m.Combo("").Get(repo.ListPushMirrors).
|
m.Combo("").Get(repo.ListPushMirrors).
|
||||||
Post(bind(api.CreatePushMirrorOption{}), repo.AddPushMirror)
|
Post(mustNotBeArchived, bind(api.CreatePushMirrorOption{}), repo.AddPushMirror)
|
||||||
m.Combo("/{name}").
|
m.Combo("/{name}").
|
||||||
Delete(repo.DeletePushMirrorByRemoteName).
|
Delete(mustNotBeArchived, repo.DeletePushMirrorByRemoteName).
|
||||||
Get(repo.GetPushMirrorByName)
|
Get(repo.GetPushMirrorByName)
|
||||||
}, reqAdmin(), reqToken())
|
}, reqAdmin(), reqToken())
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ func SettingsPost(ctx *context.Context) {
|
|||||||
ctx.Redirect(repo.Link() + "/settings")
|
ctx.Redirect(repo.Link() + "/settings")
|
||||||
|
|
||||||
case "mirror":
|
case "mirror":
|
||||||
if !setting.Mirror.Enabled || !repo.IsMirror {
|
if !setting.Mirror.Enabled || !repo.IsMirror || repo.IsArchived {
|
||||||
ctx.NotFound("", nil)
|
ctx.NotFound("", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -278,7 +278,7 @@ func SettingsPost(ctx *context.Context) {
|
|||||||
ctx.Redirect(repo.Link() + "/settings")
|
ctx.Redirect(repo.Link() + "/settings")
|
||||||
|
|
||||||
case "mirror-sync":
|
case "mirror-sync":
|
||||||
if !setting.Mirror.Enabled || !repo.IsMirror {
|
if !setting.Mirror.Enabled || !repo.IsMirror || repo.IsArchived {
|
||||||
ctx.NotFound("", nil)
|
ctx.NotFound("", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -306,7 +306,7 @@ func SettingsPost(ctx *context.Context) {
|
|||||||
ctx.Redirect(repo.Link() + "/settings")
|
ctx.Redirect(repo.Link() + "/settings")
|
||||||
|
|
||||||
case "push-mirror-update":
|
case "push-mirror-update":
|
||||||
if !setting.Mirror.Enabled {
|
if !setting.Mirror.Enabled || repo.IsArchived {
|
||||||
ctx.NotFound("", nil)
|
ctx.NotFound("", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -343,7 +343,7 @@ func SettingsPost(ctx *context.Context) {
|
|||||||
ctx.Redirect(repo.Link() + "/settings")
|
ctx.Redirect(repo.Link() + "/settings")
|
||||||
|
|
||||||
case "push-mirror-remove":
|
case "push-mirror-remove":
|
||||||
if !setting.Mirror.Enabled {
|
if !setting.Mirror.Enabled || repo.IsArchived {
|
||||||
ctx.NotFound("", nil)
|
ctx.NotFound("", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -372,7 +372,7 @@ func SettingsPost(ctx *context.Context) {
|
|||||||
ctx.Redirect(repo.Link() + "/settings")
|
ctx.Redirect(repo.Link() + "/settings")
|
||||||
|
|
||||||
case "push-mirror-add":
|
case "push-mirror-add":
|
||||||
if setting.Mirror.DisableNewPush {
|
if setting.Mirror.DisableNewPush || repo.IsArchived {
|
||||||
ctx.NotFound("", nil)
|
ctx.NotFound("", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,11 @@
|
|||||||
{{ctx.Locale.Tr "repo.settings.mirror_settings"}}
|
{{ctx.Locale.Tr "repo.settings.mirror_settings"}}
|
||||||
</h4>
|
</h4>
|
||||||
<div class="ui attached segment">
|
<div class="ui attached segment">
|
||||||
|
{{if .Repository.IsArchived}}
|
||||||
|
<div class="ui warning message gt-text-center">
|
||||||
|
{{ctx.Locale.Tr "repo.settings.archive.mirrors_unavailable"}}
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
{{if $newMirrorsEntirelyEnabled}}
|
{{if $newMirrorsEntirelyEnabled}}
|
||||||
{{ctx.Locale.Tr "repo.settings.mirror_settings.docs"}}
|
{{ctx.Locale.Tr "repo.settings.mirror_settings.docs"}}
|
||||||
<a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.com/usage/repo-mirror#pushing-to-a-remote-repository">{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br><br>
|
<a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.com/usage/repo-mirror#pushing-to-a-remote-repository">{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br><br>
|
||||||
@ -279,6 +284,7 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user