Skip to content

Commit 950c474

Browse files
committed
Merge remote-tracking branch 'origin/main' into add-pprof-to-admin-pages
2 parents d37978e + c07199f commit 950c474

File tree

114 files changed

+2664
-787
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+2664
-787
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ linters-settings:
8484
- github.com/unknwon/com: "use gitea's util and replacements"
8585
- io/ioutil: "use os or io instead"
8686
- golang.org/x/exp: "it's experimental and unreliable."
87+
- code.gitea.io/gitea/modules/git/internal: "do not use the internal package, use AddXxx function instead"
8788

8889
issues:
8990
max-issues-per-linter: 0

cmd/admin.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,12 +578,16 @@ func runCreateUser(c *cli.Context) error {
578578
restricted = util.OptionalBoolOf(c.Bool("restricted"))
579579
}
580580

581+
// default user visibility in app.ini
582+
visibility := setting.Service.DefaultUserVisibilityMode
583+
581584
u := &user_model.User{
582585
Name: username,
583586
Email: c.String("email"),
584587
Passwd: password,
585588
IsAdmin: c.Bool("admin"),
586589
MustChangePassword: changePassword,
590+
Visibility: visibility,
587591
}
588592

589593
overwriteDefault := &user_model.CreateUserOverwriteOptions{

custom/conf/app.example.ini

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ ROUTER = console
765765
;; Enable this to require captcha validation for login
766766
;REQUIRE_CAPTCHA_FOR_LOGIN = false
767767
;;
768-
;; Type of captcha you want to use. Options: image, recaptcha, hcaptcha, mcaptcha.
768+
;; Type of captcha you want to use. Options: image, recaptcha, hcaptcha, mcaptcha, cfturnstile.
769769
;CAPTCHA_TYPE = image
770770
;;
771771
;; Change this to use recaptcha.net or other recaptcha service
@@ -787,6 +787,10 @@ ROUTER = console
787787
;MCAPTCHA_SECRET =
788788
;MCAPTCHA_SITEKEY =
789789
;;
790+
;; Go to https://dash.cloudflare.com/?to=/:account/turnstile to sign up for a key
791+
;CF_TURNSTILE_SITEKEY =
792+
;CF_TURNSTILE_SECRET =
793+
;;
790794
;; Default value for KeepEmailPrivate
791795
;; Each new user will get the value of this setting copied into their profile
792796
;DEFAULT_KEEP_EMAIL_PRIVATE = false
@@ -927,14 +931,18 @@ ROUTER = console
927931
;USE_COMPAT_SSH_URI = false
928932
;;
929933
;; Close issues as long as a commit on any branch marks it as fixed
930-
;; Comma separated list of globally disabled repo units. Allowed values: repo.issues, repo.ext_issues, repo.pulls, repo.wiki, repo.ext_wiki, repo.projects
934+
;; Comma separated list of globally disabled repo units. Allowed values: repo.issues, repo.ext_issues, repo.pulls, repo.wiki, repo.ext_wiki, repo.projects, repo.packages
931935
;DISABLED_REPO_UNITS =
932936
;;
933-
;; Comma separated list of default repo units. Allowed values: repo.code, repo.releases, repo.issues, repo.pulls, repo.wiki, repo.projects.
937+
;; Comma separated list of default new repo units. Allowed values: repo.code, repo.releases, repo.issues, repo.pulls, repo.wiki, repo.projects, repo.packages.
934938
;; Note: Code and Releases can currently not be deactivated. If you specify default repo units you should still list them for future compatibility.
935939
;; External wiki and issue tracker can't be enabled by default as it requires additional settings.
936940
;; Disabled repo units will not be added to new repositories regardless if it is in the default list.
937-
;DEFAULT_REPO_UNITS = repo.code,repo.releases,repo.issues,repo.pulls,repo.wiki,repo.projects
941+
;DEFAULT_REPO_UNITS = repo.code,repo.releases,repo.issues,repo.pulls,repo.wiki,repo.projects,repo.packages
942+
;;
943+
;; Comma separated list of default forked repo units.
944+
;; The set of allowed values and rules are the same as DEFAULT_REPO_UNITS.
945+
;DEFAULT_FORK_REPO_UNITS = repo.code,repo.pulls
938946
;;
939947
;; Prefix archive files by placing them in a directory named after the repository
940948
;PREFIX_ARCHIVE_FILES = true
@@ -1218,10 +1226,6 @@ ROUTER = console
12181226
;;
12191227
;; Whether to enable a Service Worker to cache frontend assets
12201228
;USE_SERVICE_WORKER = false
1221-
;;
1222-
;; Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
1223-
;; A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
1224-
;ONLY_SHOW_RELEVANT_REPOS = false
12251229

12261230
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12271231
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2454,6 +2458,8 @@ ROUTER = console
24542458
;LIMIT_TOTAL_OWNER_COUNT = -1
24552459
;; Maximum size of packages a single owner can use (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
24562460
;LIMIT_TOTAL_OWNER_SIZE = -1
2461+
;; Maximum size of a Cargo upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2462+
;LIMIT_SIZE_CARGO = -1
24572463
;; Maximum size of a Composer upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
24582464
;LIMIT_SIZE_COMPOSER = -1
24592465
;; Maximum size of a Conan upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ In addition there is _`StaticRootPath`_ which can be set as a built-in at build
104104
- `ENABLE_PUSH_CREATE_USER`: **false**: Allow users to push local repositories to Gitea and have them automatically created for a user.
105105
- `ENABLE_PUSH_CREATE_ORG`: **false**: Allow users to push local repositories to Gitea and have them automatically created for an org.
106106
- `DISABLED_REPO_UNITS`: **_empty_**: Comma separated list of globally disabled repo units. Allowed values: \[repo.issues, repo.ext_issues, repo.pulls, repo.wiki, repo.ext_wiki, repo.projects\]
107-
- `DEFAULT_REPO_UNITS`: **repo.code,repo.releases,repo.issues,repo.pulls,repo.wiki,repo.projects**: Comma separated list of default repo units. Allowed values: \[repo.code, repo.releases, repo.issues, repo.pulls, repo.wiki, repo.projects\]. Note: Code and Releases can currently not be deactivated. If you specify default repo units you should still list them for future compatibility. External wiki and issue tracker can't be enabled by default as it requires additional settings. Disabled repo units will not be added to new repositories regardless if it is in the default list.
107+
- `DEFAULT_REPO_UNITS`: **repo.code,repo.releases,repo.issues,repo.pulls,repo.wiki,repo.projects,repo.packages**: Comma separated list of default new repo units. Allowed values: \[repo.code, repo.releases, repo.issues, repo.pulls, repo.wiki, repo.projects\]. Note: Code and Releases can currently not be deactivated. If you specify default repo units you should still list them for future compatibility. External wiki and issue tracker can't be enabled by default as it requires additional settings. Disabled repo units will not be added to new repositories regardless if it is in the default list.
108+
- `DEFAULT_FORK_REPO_UNITS`: **repo.code,repo.pulls**: Comma separated list of default forked repo units. The set of allowed values and rules is the same as `DEFAULT_REPO_UNITS`.
108109
- `PREFIX_ARCHIVE_FILES`: **true**: Prefix archive files by placing them in a directory named after the repository.
109110
- `DISABLE_MIGRATIONS`: **false**: Disable migrating feature.
110111
- `DISABLE_STARS`: **false**: Disable stars feature.
@@ -230,8 +231,6 @@ The following configuration set `Content-Type: application/vnd.android.package-a
230231
- `DEFAULT_SHOW_FULL_NAME`: **false**: Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used.
231232
- `SEARCH_REPO_DESCRIPTION`: **true**: Whether to search within description at repository search on explore page.
232233
- `USE_SERVICE_WORKER`: **false**: Whether to enable a Service Worker to cache frontend assets.
233-
- `ONLY_SHOW_RELEVANT_REPOS`: **false** Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
234-
A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
235234

236235
### UI - Admin (`ui.admin`)
237236

@@ -644,7 +643,7 @@ Certain queues have defaults that override the defaults set in `[queue]` (this o
644643
- `REQUIRE_CAPTCHA_FOR_LOGIN`: **false**: Enable this to require captcha validation for login. You also must enable `ENABLE_CAPTCHA`.
645644
- `REQUIRE_EXTERNAL_REGISTRATION_CAPTCHA`: **false**: Enable this to force captcha validation
646645
even for External Accounts (i.e. GitHub, OpenID Connect, etc). You also must enable `ENABLE_CAPTCHA`.
647-
- `CAPTCHA_TYPE`: **image**: \[image, recaptcha, hcaptcha, mcaptcha\]
646+
- `CAPTCHA_TYPE`: **image**: \[image, recaptcha, hcaptcha, mcaptcha, cfturnstile\]
648647
- `RECAPTCHA_SECRET`: **""**: Go to https://www.google.com/recaptcha/admin to get a secret for recaptcha.
649648
- `RECAPTCHA_SITEKEY`: **""**: Go to https://www.google.com/recaptcha/admin to get a sitekey for recaptcha.
650649
- `RECAPTCHA_URL`: **https://www.google.com/recaptcha/**: Set the recaptcha url - allows the use of recaptcha net.
@@ -653,6 +652,8 @@ Certain queues have defaults that override the defaults set in `[queue]` (this o
653652
- `MCAPTCHA_SECRET`: **""**: Go to your mCaptcha instance to get a secret for mCaptcha.
654653
- `MCAPTCHA_SITEKEY`: **""**: Go to your mCaptcha instance to get a sitekey for mCaptcha.
655654
- `MCAPTCHA_URL` **https://demo.mcaptcha.org/**: Set the mCaptcha URL.
655+
- `CF_TURNSTILE_SECRET` **""**: Go to https://dash.cloudflare.com/?to=/:account/turnstile to get a secret for cloudflare turnstile.
656+
- `CF_TURNSTILE_SITEKEY` **""**: Go to https://dash.cloudflare.com/?to=/:account/turnstile to get a sitekey for cloudflare turnstile.
656657
- `DEFAULT_KEEP_EMAIL_PRIVATE`: **false**: By default set users to keep their email address private.
657658
- `DEFAULT_ALLOW_CREATE_ORGANIZATION`: **true**: Allow new users to create organizations by default.
658659
- `DEFAULT_USER_IS_RESTRICTED`: **false**: Give new users restricted permissions by default
@@ -1212,6 +1213,7 @@ Task queue configuration has been moved to `queue.task`. However, the below conf
12121213
- `CHUNKED_UPLOAD_PATH`: **tmp/package-upload**: Path for chunked uploads. Defaults to `APP_DATA_PATH` + `tmp/package-upload`
12131214
- `LIMIT_TOTAL_OWNER_COUNT`: **-1**: Maximum count of package versions a single owner can have (`-1` means no limits)
12141215
- `LIMIT_TOTAL_OWNER_SIZE`: **-1**: Maximum size of packages a single owner can use (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1216+
- `LIMIT_SIZE_CARGO`: **-1**: Maximum size of a Cargo upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12151217
- `LIMIT_SIZE_COMPOSER`: **-1**: Maximum size of a Composer upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12161218
- `LIMIT_SIZE_CONAN`: **-1**: Maximum size of a Conan upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12171219
- `LIMIT_SIZE_CONDA`: **-1**: Maximum size of a Conda upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,17 @@ menu:
147147
- `ENABLE_REVERSE_PROXY_AUTO_REGISTRATION`: 允许通过反向认证做自动注册。
148148
- `ENABLE_CAPTCHA`: **false**: 注册时使用图片验证码。
149149
- `REQUIRE_CAPTCHA_FOR_LOGIN`: **false**: 登录时需要图片验证码。需要同时开启 `ENABLE_CAPTCHA`
150+
- `CAPTCHA_TYPE`: **image**: \[image, recaptcha, hcaptcha, mcaptcha, cfturnstile\],人机验证类型,分别表示图片认证、 recaptcha 、 hcaptcha 、mcaptcha 、和 cloudlfare 的 turnstile。
151+
- `RECAPTCHA_SECRET`: **""**: recaptcha 服务的密钥,可在 https://www.google.com/recaptcha/admin 获取。
152+
- `RECAPTCHA_SITEKEY`: **""**: recaptcha 服务的网站密钥 ,可在 https://www.google.com/recaptcha/admin 获取。
153+
- `RECAPTCHA_URL`: **https://www.google.com/recaptcha/**: 设置 recaptcha 的 url 。
154+
- `HCAPTCHA_SECRET`: **""**: hcaptcha 服务的密钥,可在 https://www.hcaptcha.com/ 获取。
155+
- `HCAPTCHA_SITEKEY`: **""**: hcaptcha 服务的网站密钥,可在 https://www.hcaptcha.com/ 获取。
156+
- `MCAPTCHA_SECRET`: **""**: mCaptcha 服务的密钥。
157+
- `MCAPTCHA_SITEKEY`: **""**: mCaptcha 服务的网站密钥。
158+
- `MCAPTCHA_URL` **https://demo.mcaptcha.org/**: 设置 remCaptchacaptcha 的 url 。
159+
- `CF_TURNSTILE_SECRET` **""**: cloudlfare turnstile 服务的密钥,可在 https://dash.cloudflare.com/?to=/:account/turnstile 获取。
160+
- `CF_TURNSTILE_SITEKEY` **""**: cloudlfare turnstile 服务的网站密钥 ,可在 https://www.google.com/recaptcha/admin 获取。
150161

151162
### Service - Expore (`service.explore`)
152163

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
date: "2022-11-20T00:00:00+00:00"
3+
title: "Cargo Packages Repository"
4+
slug: "packages/cargo"
5+
draft: false
6+
toc: false
7+
menu:
8+
sidebar:
9+
parent: "packages"
10+
name: "Cargo"
11+
weight: 5
12+
identifier: "cargo"
13+
---
14+
15+
# Cargo Packages Repository
16+
17+
Publish [Cargo](https://doc.rust-lang.org/stable/cargo/) packages for your user or organization.
18+
19+
**Table of Contents**
20+
21+
{{< toc >}}
22+
23+
## Requirements
24+
25+
To work with the Cargo package registry, you need [Rust and Cargo](https://www.rust-lang.org/tools/install).
26+
27+
Cargo stores informations about the available packages in a package index stored in a git repository.
28+
This repository is needed to work with the registry.
29+
The following section describes how to create it.
30+
31+
## Index Repository
32+
33+
Cargo stores informations about the available packages in a package index stored in a git repository.
34+
In Gitea this repository has the special name `_cargo-index`.
35+
After a package was uploaded, its metadata is automatically written to the index.
36+
The content of this repository should not be manually modified.
37+
38+
The user or organization package settings page allows to create the index repository along with the configuration file.
39+
If needed this action will rewrite the configuration file.
40+
This can be useful if for example the Gitea instance domain was changed.
41+
42+
If the case arises where the packages stored in Gitea and the information in the index repository are out of sync, the settings page allows to rebuild the index repository.
43+
This action iterates all packages in the registry and writes their information to the index.
44+
If there are lot of packages this process may take some time.
45+
46+
## Configuring the package registry
47+
48+
To register the package registry the Cargo configuration must be updated.
49+
Add the following text to the configuration file located in the current users home directory (for example `~/.cargo/config.toml`):
50+
51+
```
52+
[registry]
53+
default = "gitea"
54+
55+
[registries.gitea]
56+
index = "https://gitea.example.com/{owner}/_cargo-index.git"
57+
58+
[net]
59+
git-fetch-with-cli = true
60+
```
61+
62+
| Parameter | Description |
63+
| --------- | ----------- |
64+
| `owner` | The owner of the package. |
65+
66+
If the registry is private or you want to publish new packages, you have to configure your credentials.
67+
Add the credentials section to the credentials file located in the current users home directory (for example `~/.cargo/credentials.toml`):
68+
69+
```
70+
[registries.gitea]
71+
token = "Bearer {token}"
72+
```
73+
74+
| Parameter | Description |
75+
| --------- | ----------- |
76+
| `token` | Your [personal access token]({{< relref "doc/developers/api-usage.en-us.md#authentication" >}}) |
77+
78+
## Publish a package
79+
80+
Publish a package by running the following command in your project:
81+
82+
```shell
83+
cargo publish
84+
```
85+
86+
You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.
87+
88+
## Install a package
89+
90+
To install a package from the package registry, execute the following command:
91+
92+
```shell
93+
cargo add {package_name}
94+
```
95+
96+
| Parameter | Description |
97+
| -------------- | ----------- |
98+
| `package_name` | The package name. |
99+
100+
## Supported commands
101+
102+
```
103+
cargo publish
104+
cargo add
105+
cargo install
106+
cargo yank
107+
cargo unyank
108+
cargo search
109+
```

docs/content/doc/packages/overview.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ The following package managers are currently supported:
2626

2727
| Name | Language | Package client |
2828
| ---- | -------- | -------------- |
29+
| [Cargo]({{< relref "doc/packages/cargo.en-us.md" >}}) | Rust | `cargo` |
2930
| [Composer]({{< relref "doc/packages/composer.en-us.md" >}}) | PHP | `composer` |
3031
| [Conan]({{< relref "doc/packages/conan.en-us.md" >}}) | C++ | `conan` |
3132
| [Conda]({{< relref "doc/packages/conda.en-us.md" >}}) | - | `conda` |

models/db/search.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,9 @@ const (
2727
SearchOrderByForks SearchOrderBy = "num_forks ASC"
2828
SearchOrderByForksReverse SearchOrderBy = "num_forks DESC"
2929
)
30+
31+
const (
32+
// Which means a condition to filter the records which don't match any id.
33+
// It's different from zero which means the condition could be ignored.
34+
NoneID = -1
35+
)

models/issues/issue.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,8 @@ func (opts *IssuesOptions) setupSessionNoLimit(sess *xorm.Session) {
12511251
if opts.ProjectID > 0 {
12521252
sess.Join("INNER", "project_issue", "issue.id = project_issue.issue_id").
12531253
And("project_issue.project_id=?", opts.ProjectID)
1254+
} else if opts.ProjectID == db.NoneID { // show those that are in no project
1255+
sess.And(builder.NotIn("issue.id", builder.Select("issue_id").From("project_issue")))
12541256
}
12551257

12561258
if opts.ProjectBoardID != 0 {

0 commit comments

Comments
 (0)