mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-06-23 17:00:03 +02:00
Allow admins to fork repos even when creation limits are exhausted (#3277)
This is a continuation of #2728, with a test case added.
Fixes #2633.
I kept @zareck 's commit as is, because I believe it is correct. We can't move the check to `owner.CanForkRepo()`, because `owner` is the future owner of the forked repo, and may be an organization. We need to check the admin permission of the `doer`, like in the case of repository creation.
I verified that the test fails without the `ForkRepository` change, and passes with it.
Co-authored-by: Cassio Zareck <cassiomilczareck@gmail.com>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3277
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Gergely Nagy <forgejo@gergo.csillger.hu>
Co-committed-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit ea4071ca9f
)
This commit is contained in:
parent
515d71bffa
commit
261fc87673
2 changed files with 64 additions and 1 deletions
|
@ -54,7 +54,7 @@ type ForkRepoOptions struct {
|
|||
// ForkRepository forks a repository
|
||||
func ForkRepository(ctx context.Context, doer, owner *user_model.User, opts ForkRepoOptions) (*repo_model.Repository, error) {
|
||||
// Fork is prohibited, if user has reached maximum limit of repositories
|
||||
if !owner.CanForkRepo() {
|
||||
if !doer.IsAdmin && !owner.CanForkRepo() {
|
||||
return nil, repo_model.ErrReachLimitOfRepo{
|
||||
Limit: owner.MaxRepoCreation,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue