forked from NYANDEV/forgejo
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:
parent
22a6e97597
commit
7cc7db73b9
9 changed files with 53 additions and 2 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"code.gitea.io/gitea/models/unittest"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
@ -29,4 +30,19 @@ func TestForkRepository(t *testing.T) {
|
|||
assert.Nil(t, fork)
|
||||
assert.Error(t, err)
|
||||
assert.True(t, IsErrForkAlreadyExist(err))
|
||||
|
||||
// user not reached maximum limit of repositories
|
||||
assert.False(t, repo_model.IsErrReachLimitOfRepo(err))
|
||||
|
||||
// change AllowForkWithoutMaximumLimit to false for the test
|
||||
setting.Repository.AllowForkWithoutMaximumLimit = false
|
||||
// user has reached maximum limit of repositories
|
||||
user.MaxRepoCreation = 0
|
||||
fork2, err := ForkRepository(git.DefaultContext, user, user, ForkRepoOptions{
|
||||
BaseRepo: repo,
|
||||
Name: "test",
|
||||
Description: "test",
|
||||
})
|
||||
assert.Nil(t, fork2)
|
||||
assert.True(t, repo_model.IsErrReachLimitOfRepo(err))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue