mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-30 19:08:37 +00:00 
			
		
		
		
	Add option to prohibit fork if user reached maximum limit of repositories (#21848)
If user has reached the maximum limit of repositories: - Before - disallow create - allow fork without limit - This patch: - disallow create - disallow fork - Add option `ALLOW_FORK_WITHOUT_MAXIMUM_LIMIT` (Default **true**) : enable this allow user fork repositories without maximum number limit fixed https://github.com/go-gitea/gitea/issues/21847 Signed-off-by: Xinyu Zhou <i@sourcehut.net>
This commit is contained in:
		| @@ -51,6 +51,13 @@ 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() { | ||||
| 		return nil, repo_model.ErrReachLimitOfRepo{ | ||||
| 			Limit: owner.MaxRepoCreation, | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	forkedRepo, err := repo_model.GetUserFork(ctx, opts.BaseRepo.ID, owner.ID) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
|   | ||||
		Reference in New Issue
	
	Block a user