Skip to content

Commit 08be2f2

Browse files
author
Gusted
committed
Merge branch 'main' into publickey-auth-push-mirror
2 parents b57c09b + 4691e59 commit 08be2f2

File tree

244 files changed

+2744
-682
lines changed

Some content is hidden

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

244 files changed

+2744
-682
lines changed

build.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build vendor
6-
// +build vendor
76

87
package main
98

build/code-batch-process.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build ignore
6-
// +build ignore
76

87
package main
98

build/generate-bindata.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build ignore
6-
// +build ignore
76

87
package main
98

build/generate-emoji.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// license that can be found in the LICENSE file.
55

66
//go:build ignore
7-
// +build ignore
87

98
package main
109

build/generate-gitignores.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build ignore
2-
// +build ignore
32

43
package main
54

build/generate-licenses.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build ignore
2-
// +build ignore
32

43
package main
54

build/gitea-format-imports.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build ignore
6-
// +build ignore
76

87
package main
98

build/gocovmerge.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// merges them into one profile
88

99
//go:build ignore
10-
// +build ignore
1110

1211
package main
1312

cmd/admin.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
repo_module "code.gitea.io/gitea/modules/repository"
2626
"code.gitea.io/gitea/modules/setting"
2727
"code.gitea.io/gitea/modules/storage"
28+
"code.gitea.io/gitea/modules/util"
2829
auth_service "code.gitea.io/gitea/services/auth"
2930
"code.gitea.io/gitea/services/auth/source/oauth2"
3031
"code.gitea.io/gitea/services/auth/source/smtp"
@@ -114,6 +115,10 @@ var (
114115
Name: "access-token",
115116
Usage: "Generate access token for the user",
116117
},
118+
cli.BoolFlag{
119+
Name: "restricted",
120+
Usage: "Make a restricted user account",
121+
},
117122
},
118123
}
119124

@@ -551,25 +556,34 @@ func runCreateUser(c *cli.Context) error {
551556

552557
// If this is the first user being created.
553558
// Take it as the admin and don't force a password update.
554-
if n := user_model.CountUsers(); n == 0 {
559+
if n := user_model.CountUsers(nil); n == 0 {
555560
changePassword = false
556561
}
557562

558563
if c.IsSet("must-change-password") {
559564
changePassword = c.Bool("must-change-password")
560565
}
561566

567+
restricted := util.OptionalBoolNone
568+
569+
if c.IsSet("restricted") {
570+
restricted = util.OptionalBoolOf(c.Bool("restricted"))
571+
}
572+
562573
u := &user_model.User{
563574
Name: username,
564575
Email: c.String("email"),
565576
Passwd: password,
566-
IsActive: true,
567577
IsAdmin: c.Bool("admin"),
568578
MustChangePassword: changePassword,
569-
Theme: setting.UI.DefaultTheme,
570579
}
571580

572-
if err := user_model.CreateUser(u); err != nil {
581+
overwriteDefault := &user_model.CreateUserOverwriteOptions{
582+
IsActive: util.OptionalBoolTrue,
583+
IsRestricted: restricted,
584+
}
585+
586+
if err := user_model.CreateUser(u, overwriteDefault); err != nil {
573587
return fmt.Errorf("CreateUser: %v", err)
574588
}
575589

cmd/embedded.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build bindata
6-
// +build bindata
76

87
package cmd
98

cmd/embedded_stub.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build !bindata
6-
// +build !bindata
76

87
package cmd
98

custom/conf/app.example.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,6 +2240,9 @@ PATH =
22402240
;;
22412241
;; Enable/Disable federation capabilities
22422242
; ENABLED = true
2243+
;;
2244+
;; Enable/Disable user statistics for nodeinfo if federation is enabled
2245+
; SHARE_USER_STATISTICS = true
22432246

22442247
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22452248
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,7 @@ Task queue configuration has been moved to `queue.task`. However, the below conf
10851085
## Federation (`federation`)
10861086

10871087
- `ENABLED`: **true**: Enable/Disable federation capabilities
1088+
- `SHARE_USER_STATISTICS`: **true**: Enable/Disable user statistics for nodeinfo if federation is enabled
10881089

10891090
## Packages (`packages`)
10901091

docs/content/doc/advanced/customizing-gitea.en-us.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,18 @@ copy javascript files from https://gitea.com/davidsvantesson/plantuml-code-highl
132132
`$GITEA_CUSTOM/public` folder. Then add the following to `custom/footer.tmpl`:
133133

134134
```html
135-
{{if .RequireHighlightJS}}
136-
<script src="https://your-server.com/deflate.js"></script>
137-
<script src="https://your-server.com/encode.js"></script>
138-
<script src="https://your-server.com/plantuml_codeblock_parse.js"></script>
139135
<script>
140-
<!-- Replace call with address to your plantuml server-->
141-
parsePlantumlCodeBlocks("http://www.plantuml.com/plantuml");
136+
$(async () => {
137+
if (!$('.language-plantuml').length) return;
138+
await Promise.all([
139+
$.getScript('https://your-server.com/deflate.js'),
140+
$.getScript('https://your-server.com/encode.js'),
141+
$.getScript('https://your-server.com/plantuml_codeblock_parse.js'),
142+
]);
143+
// Replace call with address to your plantuml server
144+
parsePlantumlCodeBlocks("https://www.plantuml.com/plantuml");
145+
});
142146
</script>
143-
{{end}}
144147
```
145148

146149
You can then add blocks like the following to your markdown:

docs/content/doc/installation/from-binary.en-us.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ Of note, configuring `GITEA_WORK_DIR` will tell Gitea where to base its working
5050

5151
### Prepare environment
5252

53-
Check that Git is installed on the server. If it is not, install it first.
53+
Check that Git is installed on the server. If it is not, install it first. Gitea requires Git version >= 2.0.
54+
5455
```sh
5556
git --version
5657
```

docs/content/doc/installation/on-kubernetes.en-us.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,47 @@ helm install gitea gitea-charts/gitea
2525
```
2626

2727
If you would like to customize your install, which includes kubernetes ingress, please refer to the complete [Gitea helm chart configuration details](https://gitea.com/gitea/helm-chart/)
28+
29+
## Health check endpoint
30+
31+
Gitea comes with a health check endpoint `/api/healthz`, you can configure it in kubernetes like this:
32+
33+
```yaml
34+
livenessProbe:
35+
httpGet:
36+
path: /api/healthz
37+
port: http
38+
initialDelaySeconds: 200
39+
timeoutSeconds: 5
40+
periodSeconds: 10
41+
successThreshold: 1
42+
failureThreshold: 10
43+
```
44+
45+
a successful health check response will respond with http code `200`, here's example:
46+
47+
```
48+
HTTP/1.1 200 OK
49+
50+
51+
{
52+
"status": "pass",
53+
"description": "Gitea: Git with a cup of tea",
54+
"checks": {
55+
"cache:ping": [
56+
{
57+
"status": "pass",
58+
"time": "2022-02-19T09:16:08Z"
59+
}
60+
],
61+
"database:ping": [
62+
{
63+
"status": "pass",
64+
"time": "2022-02-19T09:16:08Z"
65+
}
66+
]
67+
}
68+
}
69+
```
70+
71+
for more information, please reference to kubernetes documentation [Define a liveness HTTP request](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-liveness-http-request)

docs/content/doc/installation/on-kubernetes.zh-tw.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,47 @@ helm install gitea gitea-charts/gitea
2525
```
2626

2727
若您想自訂安裝(包括使用 kubernetes ingress),請前往完整的 [Gitea helm chart configuration details](https://gitea.com/gitea/helm-chart/)
28+
29+
##運行狀況檢查終端節點
30+
31+
Gitea 附帶了一個運行狀況檢查端點 `/api/healthz`,你可以像這樣在 kubernetes 中配置它:
32+
33+
```yaml
34+
livenessProbe:
35+
httpGet:
36+
path: /api/healthz
37+
port: http
38+
initialDelaySeconds: 200
39+
timeoutSeconds: 5
40+
periodSeconds: 10
41+
successThreshold: 1
42+
failureThreshold: 10
43+
```
44+
45+
成功的運行狀況檢查回應將使用 HTTP 代碼 `200` 進行回應,下面是示例:
46+
47+
```
48+
HTTP/1.1 200 OK
49+
50+
51+
{
52+
"status": "pass",
53+
"description": "Gitea: Git with a cup of tea",
54+
"checks": {
55+
"cache:ping": [
56+
{
57+
"status": "pass",
58+
"time": "2022-02-19T09:16:08Z"
59+
}
60+
],
61+
"database:ping": [
62+
{
63+
"status": "pass",
64+
"time": "2022-02-19T09:16:08Z"
65+
}
66+
]
67+
}
68+
}
69+
```
70+
71+
有關更多信息,請參考kubernetes文檔[定義一個存活態 HTTP請求接口](https://kubernetes.io/zh/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/)

integrations/api_nodeinfo_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ func TestNodeinfo(t *testing.T) {
2626
resp := MakeRequest(t, req, http.StatusOK)
2727
var nodeinfo api.NodeInfo
2828
DecodeJSON(t, resp, &nodeinfo)
29+
assert.True(t, nodeinfo.OpenRegistrations)
2930
assert.Equal(t, "gitea", nodeinfo.Software.Name)
31+
assert.Equal(t, 23, nodeinfo.Usage.Users.Total)
32+
assert.Equal(t, 15, nodeinfo.Usage.LocalPosts)
33+
assert.Equal(t, 2, nodeinfo.Usage.LocalComments)
3034
})
3135
}

0 commit comments

Comments
 (0)