From 4eb0c132575be0c401cf772198c13eed06433831 Mon Sep 17 00:00:00 2001 From: Tait Hoyem Date: Thu, 24 Sep 2020 15:16:50 +0000 Subject: [PATCH 1/7] Add config option to make create-on-push repositories public by default --- modules/setting/repository.go | 2 ++ services/repository/repository.go | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/setting/repository.go b/modules/setting/repository.go index 67dd80535338d..2822d661da5b1 100644 --- a/modules/setting/repository.go +++ b/modules/setting/repository.go @@ -29,6 +29,7 @@ var ( AnsiCharset string ForcePrivate bool DefaultPrivate string + DefaultPushCreatePrivate bool MaxCreationLimit int MirrorQueueLength int PullRequestQueueLength int @@ -132,6 +133,7 @@ var ( AnsiCharset: "", ForcePrivate: false, DefaultPrivate: RepoCreatingLastUserVisibility, + DefaultPushCreatePrivate: true, MaxCreationLimit: -1, MirrorQueueLength: 1000, PullRequestQueueLength: 1000, diff --git a/services/repository/repository.go b/services/repository/repository.go index 77c8728d946fc..66de8f3607a46 100644 --- a/services/repository/repository.go +++ b/services/repository/repository.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/modules/notification" repo_module "code.gitea.io/gitea/modules/repository" pull_service "code.gitea.io/gitea/services/pull" + cfg "code.gitea.io/gitea/modules/setting" ) // CreateRepository creates a repository for the user/organization. @@ -79,7 +80,7 @@ func PushCreateRepo(authUser, owner *models.User, repoName string) (*models.Repo repo, err := CreateRepository(authUser, owner, models.CreateRepoOptions{ Name: repoName, - IsPrivate: true, + IsPrivate: cfg.Repository.DefaultPushCreatePrivate, }) if err != nil { return nil, err From 4cc47a1788b08b7e2a73ac9c10409bac06b33c92 Mon Sep 17 00:00:00 2001 From: Tait Hoyem Date: Thu, 24 Sep 2020 15:33:50 +0000 Subject: [PATCH 2/7] Fix linting --- modules/setting/repository.go | 4 ++-- services/repository/repository.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/setting/repository.go b/modules/setting/repository.go index 2822d661da5b1..97cf3e1610a10 100644 --- a/modules/setting/repository.go +++ b/modules/setting/repository.go @@ -29,7 +29,7 @@ var ( AnsiCharset string ForcePrivate bool DefaultPrivate string - DefaultPushCreatePrivate bool + DefaultPushCreatePrivate bool MaxCreationLimit int MirrorQueueLength int PullRequestQueueLength int @@ -133,7 +133,7 @@ var ( AnsiCharset: "", ForcePrivate: false, DefaultPrivate: RepoCreatingLastUserVisibility, - DefaultPushCreatePrivate: true, + DefaultPushCreatePrivate: true, MaxCreationLimit: -1, MirrorQueueLength: 1000, PullRequestQueueLength: 1000, diff --git a/services/repository/repository.go b/services/repository/repository.go index 66de8f3607a46..05a605d073199 100644 --- a/services/repository/repository.go +++ b/services/repository/repository.go @@ -11,8 +11,8 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/notification" repo_module "code.gitea.io/gitea/modules/repository" + cfg "code.gitea.io/gitea/modules/setting" pull_service "code.gitea.io/gitea/services/pull" - cfg "code.gitea.io/gitea/modules/setting" ) // CreateRepository creates a repository for the user/organization. From 8df3074d112ffd8a21173d09a659997d6516a609 Mon Sep 17 00:00:00 2001 From: Tait Hoyem Date: Thu, 24 Sep 2020 15:48:37 +0000 Subject: [PATCH 3/7] Add option to 'config cheat sheet' page --- docs/content/doc/advanced/config-cheat-sheet.en-us.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 1e48ee2597f76..50553cdd6128e 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -51,6 +51,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`. - `FORCE_PRIVATE`: **false**: Force every new repository to be private. - `DEFAULT_PRIVATE`: **last**: Default private when creating a new repository. \[last, private, public\] +- `DEFAULT_PUSH_PRIVATE`: **true**: Default private when creating a new repository with push-to-create. - `MAX_CREATION_LIMIT`: **-1**: Global maximum creation limit of repositories per user, `-1` means no limit. - `PULL_REQUEST_QUEUE_LENGTH`: **1000**: Length of pull request patch test queue, make it From 3688305d795c34535c049200d813de74ab8b638e Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Fri, 25 Sep 2020 00:20:12 +0800 Subject: [PATCH 4/7] Chinese translation Signed-off-by: a1012112796 <1012112796@qq.com> --- docs/content/doc/advanced/config-cheat-sheet.zh-cn.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/content/doc/advanced/config-cheat-sheet.zh-cn.md b/docs/content/doc/advanced/config-cheat-sheet.zh-cn.md index ac6c94dff2f27..3b26587c41e20 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.zh-cn.md +++ b/docs/content/doc/advanced/config-cheat-sheet.zh-cn.md @@ -30,6 +30,7 @@ menu: - `ANSI_CHARSET`: 默认字符编码。 - `FORCE_PRIVATE`: 强制所有git工程必须私有。 - `DEFAULT_PRIVATE`: 默认创建的git工程为私有。 可以是`last`, `private` 或 `public`。默认值是 `last`表示用户最后创建的Repo的选择。 +- `DEFAULT_PUSH_PRIVATE`: **true**: 通过 ``push-to-create`` 方式创建的仓库是否默认为私有仓库. - `MAX_CREATION_LIMIT`: 全局最大每个用户创建的git工程数目, `-1` 表示没限制。 - `PULL_REQUEST_QUEUE_LENGTH`: 小心:合并请求测试队列的长度,尽量放大。 From d7ed9b08cb963151294a16beb16def0648bc42dd Mon Sep 17 00:00:00 2001 From: Tait Hoyem Date: Thu, 24 Sep 2020 16:29:05 +0000 Subject: [PATCH 5/7] Fix typo in docs --- docs/content/doc/advanced/config-cheat-sheet.en-us.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 50553cdd6128e..b797e9e0f1772 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -51,7 +51,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`. - `FORCE_PRIVATE`: **false**: Force every new repository to be private. - `DEFAULT_PRIVATE`: **last**: Default private when creating a new repository. \[last, private, public\] -- `DEFAULT_PUSH_PRIVATE`: **true**: Default private when creating a new repository with push-to-create. +- `DEFAULT_PUSH_CREATE_PRIVATE`: **true**: Default private when creating a new repository with push-to-create. - `MAX_CREATION_LIMIT`: **-1**: Global maximum creation limit of repositories per user, `-1` means no limit. - `PULL_REQUEST_QUEUE_LENGTH`: **1000**: Length of pull request patch test queue, make it From e014b12bac1e85b6d11de70b413b5059904e50de Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Fri, 25 Sep 2020 00:39:00 +0800 Subject: [PATCH 6/7] fix typo --- docs/content/doc/advanced/config-cheat-sheet.zh-cn.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/doc/advanced/config-cheat-sheet.zh-cn.md b/docs/content/doc/advanced/config-cheat-sheet.zh-cn.md index 3b26587c41e20..f771f4fc8976e 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.zh-cn.md +++ b/docs/content/doc/advanced/config-cheat-sheet.zh-cn.md @@ -30,7 +30,7 @@ menu: - `ANSI_CHARSET`: 默认字符编码。 - `FORCE_PRIVATE`: 强制所有git工程必须私有。 - `DEFAULT_PRIVATE`: 默认创建的git工程为私有。 可以是`last`, `private` 或 `public`。默认值是 `last`表示用户最后创建的Repo的选择。 -- `DEFAULT_PUSH_PRIVATE`: **true**: 通过 ``push-to-create`` 方式创建的仓库是否默认为私有仓库. +- `DEFAULT_PUSH_CREATE_PRIVATE`: **true**: 通过 ``push-to-create`` 方式创建的仓库是否默认为私有仓库. - `MAX_CREATION_LIMIT`: 全局最大每个用户创建的git工程数目, `-1` 表示没限制。 - `PULL_REQUEST_QUEUE_LENGTH`: 小心:合并请求测试队列的长度,尽量放大。 From 81f75b0d79a4c228dbe6bf7aee3fc4c57ba52d11 Mon Sep 17 00:00:00 2001 From: Tait Hoyem Date: Thu, 24 Sep 2020 19:21:14 +0000 Subject: [PATCH 7/7] Add option to example config --- custom/conf/app.example.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index ffc4e406780e7..138e6e9b7781a 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -30,6 +30,8 @@ ANSI_CHARSET = FORCE_PRIVATE = false ; Default privacy setting when creating a new repository, allowed values: last, private, public. Default is last which means the last setting used. DEFAULT_PRIVATE = last +; Default private when using push-to-create +DEFAULT_PUSH_CREATE_PRIVATE = true ; Global limit of repositories per user, applied at creation time. -1 means no limit MAX_CREATION_LIMIT = -1 ; Mirror sync queue length, increase if mirror syncing starts hanging