Skip to content

Commit c85c9d4

Browse files
TTWNOTait Hoyema1012112796techknowlogick
authored
Add config option to make create-on-push repositories public by default (#12936)
* Add config option to make create-on-push repositories public by default * Fix linting * Add option to 'config cheat sheet' page * Chinese translation Signed-off-by: a1012112796 <1012112796@qq.com> * Fix typo in docs * fix typo * Add option to example config Co-authored-by: Tait Hoyem <code@tait.tech> Co-authored-by: a1012112796 <1012112796@qq.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
1 parent 82179a6 commit c85c9d4

File tree

5 files changed

+8
-1
lines changed

5 files changed

+8
-1
lines changed

custom/conf/app.example.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ ANSI_CHARSET =
3030
FORCE_PRIVATE = false
3131
; Default privacy setting when creating a new repository, allowed values: last, private, public. Default is last which means the last setting used.
3232
DEFAULT_PRIVATE = last
33+
; Default private when using push-to-create
34+
DEFAULT_PUSH_CREATE_PRIVATE = true
3335
; Global limit of repositories per user, applied at creation time. -1 means no limit
3436
MAX_CREATION_LIMIT = -1
3537
; Mirror sync queue length, increase if mirror syncing starts hanging

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
5151
- `FORCE_PRIVATE`: **false**: Force every new repository to be private.
5252
- `DEFAULT_PRIVATE`: **last**: Default private when creating a new repository.
5353
\[last, private, public\]
54+
- `DEFAULT_PUSH_CREATE_PRIVATE`: **true**: Default private when creating a new repository with push-to-create.
5455
- `MAX_CREATION_LIMIT`: **-1**: Global maximum creation limit of repositories per user,
5556
`-1` means no limit.
5657
- `PULL_REQUEST_QUEUE_LENGTH`: **1000**: Length of pull request patch test queue, make it

docs/content/doc/advanced/config-cheat-sheet.zh-cn.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ menu:
3030
- `ANSI_CHARSET`: 默认字符编码。
3131
- `FORCE_PRIVATE`: 强制所有git工程必须私有。
3232
- `DEFAULT_PRIVATE`: 默认创建的git工程为私有。 可以是`last`, `private``public`。默认值是 `last`表示用户最后创建的Repo的选择。
33+
- `DEFAULT_PUSH_CREATE_PRIVATE`: **true**: 通过 ``push-to-create`` 方式创建的仓库是否默认为私有仓库.
3334
- `MAX_CREATION_LIMIT`: 全局最大每个用户创建的git工程数目, `-1` 表示没限制。
3435
- `PULL_REQUEST_QUEUE_LENGTH`: 小心:合并请求测试队列的长度,尽量放大。
3536

modules/setting/repository.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var (
2929
AnsiCharset string
3030
ForcePrivate bool
3131
DefaultPrivate string
32+
DefaultPushCreatePrivate bool
3233
MaxCreationLimit int
3334
MirrorQueueLength int
3435
PullRequestQueueLength int
@@ -134,6 +135,7 @@ var (
134135
AnsiCharset: "",
135136
ForcePrivate: false,
136137
DefaultPrivate: RepoCreatingLastUserVisibility,
138+
DefaultPushCreatePrivate: true,
137139
MaxCreationLimit: -1,
138140
MirrorQueueLength: 1000,
139141
PullRequestQueueLength: 1000,

services/repository/repository.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"code.gitea.io/gitea/modules/log"
1212
"code.gitea.io/gitea/modules/notification"
1313
repo_module "code.gitea.io/gitea/modules/repository"
14+
cfg "code.gitea.io/gitea/modules/setting"
1415
pull_service "code.gitea.io/gitea/services/pull"
1516
)
1617

@@ -88,7 +89,7 @@ func PushCreateRepo(authUser, owner *models.User, repoName string) (*models.Repo
8889

8990
repo, err := CreateRepository(authUser, owner, models.CreateRepoOptions{
9091
Name: repoName,
91-
IsPrivate: true,
92+
IsPrivate: cfg.Repository.DefaultPushCreatePrivate,
9293
})
9394
if err != nil {
9495
return nil, err

0 commit comments

Comments
 (0)