Skip to content

Commit aca1e3b

Browse files
committed
Merge remote-tracking branch 'origin/main' into action_indices
2 parents 2f2234e + f034ee6 commit aca1e3b

File tree

332 files changed

+3375
-1467
lines changed

Some content is hidden

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

332 files changed

+3375
-1467
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,9 @@ release-sources: | $(DIST_DIRS)
646646
echo $(VERSION) > $(STORED_VERSION_FILE)
647647
# bsdtar needs a ^ to prevent matching subdirectories
648648
$(eval EXCL := --exclude=$(shell tar --help | grep -q bsdtar && echo "^")./)
649-
tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
649+
# use transform to a add a release-folder prefix; in bsdtar the transform parameter equivalent is -s
650+
$(eval TRANSFORM := $(shell tar --help | grep -q bsdtar && echo "-s '/^./gitea-src-$(VERSION)/'" || echo "--transform 's|^./|gitea-src-$(VERSION)/|'"))
651+
tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) $(TRANSFORM) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
650652
rm -f $(STORED_VERSION_FILE)
651653

652654
.PHONY: release-docs

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/dump.go

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package cmd
77

88
import (
99
"fmt"
10+
"io"
1011
"os"
1112
"path"
1213
"path/filepath"
@@ -25,10 +26,21 @@ import (
2526
"github.com/urfave/cli"
2627
)
2728

28-
func addFile(w archiver.Writer, filePath, absPath string, verbose bool) error {
29+
func addReader(w archiver.Writer, r io.ReadCloser, info os.FileInfo, customName string, verbose bool) error {
2930
if verbose {
30-
log.Info("Adding file %s\n", filePath)
31+
log.Info("Adding file %s", customName)
3132
}
33+
34+
return w.Write(archiver.File{
35+
FileInfo: archiver.FileInfo{
36+
FileInfo: info,
37+
CustomName: customName,
38+
},
39+
ReadCloser: r,
40+
})
41+
}
42+
43+
func addFile(w archiver.Writer, filePath, absPath string, verbose bool) error {
3244
file, err := os.Open(absPath)
3345
if err != nil {
3446
return err
@@ -39,13 +51,7 @@ func addFile(w archiver.Writer, filePath, absPath string, verbose bool) error {
3951
return err
4052
}
4153

42-
return w.Write(archiver.File{
43-
FileInfo: archiver.FileInfo{
44-
FileInfo: fileInfo,
45-
CustomName: filePath,
46-
},
47-
ReadCloser: file,
48-
})
54+
return addReader(w, file, fileInfo, filePath, verbose)
4955
}
5056

5157
func isSubdir(upper, lower string) (bool, error) {
@@ -136,6 +142,10 @@ It can be used for backup and capture Gitea server image to send to maintainer`,
136142
Name: "skip-attachment-data",
137143
Usage: "Skip attachment data",
138144
},
145+
cli.BoolFlag{
146+
Name: "skip-package-data",
147+
Usage: "Skip package data",
148+
},
139149
cli.GenericFlag{
140150
Name: "type",
141151
Value: outputTypeEnum,
@@ -241,13 +251,7 @@ func runDump(ctx *cli.Context) error {
241251
return err
242252
}
243253

244-
return w.Write(archiver.File{
245-
FileInfo: archiver.FileInfo{
246-
FileInfo: info,
247-
CustomName: path.Join("data", "lfs", objPath),
248-
},
249-
ReadCloser: object,
250-
})
254+
return addReader(w, object, info, path.Join("data", "lfs", objPath), verbose)
251255
}); err != nil {
252256
fatal("Failed to dump LFS objects: %v", err)
253257
}
@@ -326,6 +330,7 @@ func runDump(ctx *cli.Context) error {
326330
excludes = append(excludes, setting.RepoRootPath)
327331
excludes = append(excludes, setting.LFS.Path)
328332
excludes = append(excludes, setting.Attachment.Path)
333+
excludes = append(excludes, setting.Packages.Path)
329334
excludes = append(excludes, setting.LogRootPath)
330335
excludes = append(excludes, absFileName)
331336
if err := addRecursiveExclude(w, "data", setting.AppDataPath, excludes, verbose); err != nil {
@@ -341,17 +346,24 @@ func runDump(ctx *cli.Context) error {
341346
return err
342347
}
343348

344-
return w.Write(archiver.File{
345-
FileInfo: archiver.FileInfo{
346-
FileInfo: info,
347-
CustomName: path.Join("data", "attachments", objPath),
348-
},
349-
ReadCloser: object,
350-
})
349+
return addReader(w, object, info, path.Join("data", "attachments", objPath), verbose)
351350
}); err != nil {
352351
fatal("Failed to dump attachments: %v", err)
353352
}
354353

354+
if ctx.IsSet("skip-package-data") && ctx.Bool("skip-package-data") {
355+
log.Info("Skip dumping package data")
356+
} else if err := storage.Packages.IterateObjects(func(objPath string, object storage.Object) error {
357+
info, err := object.Stat()
358+
if err != nil {
359+
return err
360+
}
361+
362+
return addReader(w, object, info, path.Join("data", "packages", objPath), verbose)
363+
}); err != nil {
364+
fatal("Failed to dump packages: %v", err)
365+
}
366+
355367
// Doesn't check if LogRootPath exists before processing --skip-log intentionally,
356368
// ensuring that it's clear the dump is skipped whether the directory's initialized
357369
// yet or not.

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

contrib/upgrade.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424

2525
function giteacmd {
2626
if [[ $sudocmd = "su" ]]; then
27-
"$sudocmd" - "$giteauser" -c "$giteabin" --config "$giteaconf" --work-path "$giteahome" "$@"
27+
# `-c` only accept one string as argument.
28+
"$sudocmd" - "$giteauser" -c "$(printf "%q " "$giteabin" "--config" "$giteaconf" "--work-path" "$giteahome" "$@")"
2829
else
2930
"$sudocmd" --user "$giteauser" "$giteabin" --config "$giteaconf" --work-path "$giteahome" "$@"
3031
fi

custom/conf/app.example.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ INTERNAL_TOKEN=
398398
;; By modifying the Gitea database, users can gain Gitea administrator privileges.
399399
;; It also enables them to access other resources available to the user on the operating system that is running the Gitea instance and perform arbitrary actions in the name of the Gitea OS user.
400400
;; WARNING: This maybe harmful to you website or your operating system.
401+
;; WARNING: Setting this to true does not change existing hooks in git repos; adjust it before if necessary.
401402
;DISABLE_GIT_HOOKS = true
402403
;;
403404
;; Set to true to disable webhooks feature.
@@ -2239,6 +2240,9 @@ PATH =
22392240
;;
22402241
;; Enable/Disable federation capabilities
22412242
; ENABLED = true
2243+
;;
2244+
;; Enable/Disable user statistics for nodeinfo if federation is enabled
2245+
; SHARE_USER_STATISTICS = true
22422246

22432247
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22442248
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ Certain queues have defaults that override the defaults set in `[queue]` (this o
497497
It also enables them to access other resources available to the user on the operating system that is running the
498498
Gitea instance and perform arbitrary actions in the name of the Gitea OS user.
499499
This maybe harmful to you website or your operating system.
500+
Setting this to true does not change existing hooks in git repos; adjust it before if necessary.
500501
- `DISABLE_WEBHOOKS`: **false**: Set to `true` to disable webhooks feature.
501502
- `ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET`: **true**: Set to `false` to allow local users to push to gitea-repositories without setting up the Gitea environment. This is not recommended and if you want local users to push to Gitea repositories you should set the environment appropriately.
502503
- `IMPORT_LOCAL_PATHS`: **false**: Set to `false` to prevent all users (including admin) from importing local path on server.
@@ -1084,6 +1085,7 @@ Task queue configuration has been moved to `queue.task`. However, the below conf
10841085
## Federation (`federation`)
10851086

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

10881090
## Packages (`packages`)
10891091

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)

0 commit comments

Comments
 (0)