Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into action_indices
Browse files Browse the repository at this point in the history
  • Loading branch information
zeripath committed May 4, 2022
2 parents 2f2234e + f034ee6 commit aca1e3b
Show file tree
Hide file tree
Showing 332 changed files with 3,375 additions and 1,467 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,9 @@ release-sources: | $(DIST_DIRS)
echo $(VERSION) > $(STORED_VERSION_FILE)
# bsdtar needs a ^ to prevent matching subdirectories
$(eval EXCL := --exclude=$(shell tar --help | grep -q bsdtar && echo "^")./)
tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
# use transform to a add a release-folder prefix; in bsdtar the transform parameter equivalent is -s
$(eval TRANSFORM := $(shell tar --help | grep -q bsdtar && echo "-s '/^./gitea-src-$(VERSION)/'" || echo "--transform 's|^./|gitea-src-$(VERSION)/|'"))
tar $(addprefix $(EXCL),$(TAR_EXCLUDES)) $(TRANSFORM) -czf $(DIST)/release/gitea-src-$(VERSION).tar.gz .
rm -f $(STORED_VERSION_FILE)

.PHONY: release-docs
Expand Down
1 change: 0 additions & 1 deletion build.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build vendor
// +build vendor

package main

Expand Down
1 change: 0 additions & 1 deletion build/code-batch-process.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build ignore
// +build ignore

package main

Expand Down
1 change: 0 additions & 1 deletion build/generate-bindata.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build ignore
// +build ignore

package main

Expand Down
1 change: 0 additions & 1 deletion build/generate-emoji.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// license that can be found in the LICENSE file.

//go:build ignore
// +build ignore

package main

Expand Down
1 change: 0 additions & 1 deletion build/generate-gitignores.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build ignore
// +build ignore

package main

Expand Down
1 change: 0 additions & 1 deletion build/generate-licenses.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build ignore
// +build ignore

package main

Expand Down
1 change: 0 additions & 1 deletion build/gitea-format-imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build ignore
// +build ignore

package main

Expand Down
1 change: 0 additions & 1 deletion build/gocovmerge.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// merges them into one profile

//go:build ignore
// +build ignore

package main

Expand Down
22 changes: 18 additions & 4 deletions cmd/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/storage"
"code.gitea.io/gitea/modules/util"
auth_service "code.gitea.io/gitea/services/auth"
"code.gitea.io/gitea/services/auth/source/oauth2"
"code.gitea.io/gitea/services/auth/source/smtp"
Expand Down Expand Up @@ -114,6 +115,10 @@ var (
Name: "access-token",
Usage: "Generate access token for the user",
},
cli.BoolFlag{
Name: "restricted",
Usage: "Make a restricted user account",
},
},
}

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

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

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

restricted := util.OptionalBoolNone

if c.IsSet("restricted") {
restricted = util.OptionalBoolOf(c.Bool("restricted"))
}

u := &user_model.User{
Name: username,
Email: c.String("email"),
Passwd: password,
IsActive: true,
IsAdmin: c.Bool("admin"),
MustChangePassword: changePassword,
Theme: setting.UI.DefaultTheme,
}

if err := user_model.CreateUser(u); err != nil {
overwriteDefault := &user_model.CreateUserOverwriteOptions{
IsActive: util.OptionalBoolTrue,
IsRestricted: restricted,
}

if err := user_model.CreateUser(u, overwriteDefault); err != nil {
return fmt.Errorf("CreateUser: %v", err)
}

Expand Down
58 changes: 35 additions & 23 deletions cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package cmd

import (
"fmt"
"io"
"os"
"path"
"path/filepath"
Expand All @@ -25,10 +26,21 @@ import (
"github.com/urfave/cli"
)

func addFile(w archiver.Writer, filePath, absPath string, verbose bool) error {
func addReader(w archiver.Writer, r io.ReadCloser, info os.FileInfo, customName string, verbose bool) error {
if verbose {
log.Info("Adding file %s\n", filePath)
log.Info("Adding file %s", customName)
}

return w.Write(archiver.File{
FileInfo: archiver.FileInfo{
FileInfo: info,
CustomName: customName,
},
ReadCloser: r,
})
}

func addFile(w archiver.Writer, filePath, absPath string, verbose bool) error {
file, err := os.Open(absPath)
if err != nil {
return err
Expand All @@ -39,13 +51,7 @@ func addFile(w archiver.Writer, filePath, absPath string, verbose bool) error {
return err
}

return w.Write(archiver.File{
FileInfo: archiver.FileInfo{
FileInfo: fileInfo,
CustomName: filePath,
},
ReadCloser: file,
})
return addReader(w, file, fileInfo, filePath, verbose)
}

func isSubdir(upper, lower string) (bool, error) {
Expand Down Expand Up @@ -136,6 +142,10 @@ It can be used for backup and capture Gitea server image to send to maintainer`,
Name: "skip-attachment-data",
Usage: "Skip attachment data",
},
cli.BoolFlag{
Name: "skip-package-data",
Usage: "Skip package data",
},
cli.GenericFlag{
Name: "type",
Value: outputTypeEnum,
Expand Down Expand Up @@ -241,13 +251,7 @@ func runDump(ctx *cli.Context) error {
return err
}

return w.Write(archiver.File{
FileInfo: archiver.FileInfo{
FileInfo: info,
CustomName: path.Join("data", "lfs", objPath),
},
ReadCloser: object,
})
return addReader(w, object, info, path.Join("data", "lfs", objPath), verbose)
}); err != nil {
fatal("Failed to dump LFS objects: %v", err)
}
Expand Down Expand Up @@ -326,6 +330,7 @@ func runDump(ctx *cli.Context) error {
excludes = append(excludes, setting.RepoRootPath)
excludes = append(excludes, setting.LFS.Path)
excludes = append(excludes, setting.Attachment.Path)
excludes = append(excludes, setting.Packages.Path)
excludes = append(excludes, setting.LogRootPath)
excludes = append(excludes, absFileName)
if err := addRecursiveExclude(w, "data", setting.AppDataPath, excludes, verbose); err != nil {
Expand All @@ -341,17 +346,24 @@ func runDump(ctx *cli.Context) error {
return err
}

return w.Write(archiver.File{
FileInfo: archiver.FileInfo{
FileInfo: info,
CustomName: path.Join("data", "attachments", objPath),
},
ReadCloser: object,
})
return addReader(w, object, info, path.Join("data", "attachments", objPath), verbose)
}); err != nil {
fatal("Failed to dump attachments: %v", err)
}

if ctx.IsSet("skip-package-data") && ctx.Bool("skip-package-data") {
log.Info("Skip dumping package data")
} else if err := storage.Packages.IterateObjects(func(objPath string, object storage.Object) error {
info, err := object.Stat()
if err != nil {
return err
}

return addReader(w, object, info, path.Join("data", "packages", objPath), verbose)
}); err != nil {
fatal("Failed to dump packages: %v", err)
}

// Doesn't check if LogRootPath exists before processing --skip-log intentionally,
// ensuring that it's clear the dump is skipped whether the directory's initialized
// yet or not.
Expand Down
1 change: 0 additions & 1 deletion cmd/embedded.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build bindata
// +build bindata

package cmd

Expand Down
1 change: 0 additions & 1 deletion cmd/embedded_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.

//go:build !bindata
// +build !bindata

package cmd

Expand Down
3 changes: 2 additions & 1 deletion contrib/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

function giteacmd {
if [[ $sudocmd = "su" ]]; then
"$sudocmd" - "$giteauser" -c "$giteabin" --config "$giteaconf" --work-path "$giteahome" "$@"
# `-c` only accept one string as argument.
"$sudocmd" - "$giteauser" -c "$(printf "%q " "$giteabin" "--config" "$giteaconf" "--work-path" "$giteahome" "$@")"
else
"$sudocmd" --user "$giteauser" "$giteabin" --config "$giteaconf" --work-path "$giteahome" "$@"
fi
Expand Down
4 changes: 4 additions & 0 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ INTERNAL_TOKEN=
;; By modifying the Gitea database, users can gain Gitea administrator privileges.
;; 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.
;; WARNING: This maybe harmful to you website or your operating system.
;; WARNING: Setting this to true does not change existing hooks in git repos; adjust it before if necessary.
;DISABLE_GIT_HOOKS = true
;;
;; Set to true to disable webhooks feature.
Expand Down Expand Up @@ -2239,6 +2240,9 @@ PATH =
;;
;; Enable/Disable federation capabilities
; ENABLED = true
;;
;; Enable/Disable user statistics for nodeinfo if federation is enabled
; SHARE_USER_STATISTICS = true

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down
2 changes: 2 additions & 0 deletions docs/content/doc/advanced/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ Certain queues have defaults that override the defaults set in `[queue]` (this o
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.
This maybe harmful to you website or your operating system.
Setting this to true does not change existing hooks in git repos; adjust it before if necessary.
- `DISABLE_WEBHOOKS`: **false**: Set to `true` to disable webhooks feature.
- `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.
- `IMPORT_LOCAL_PATHS`: **false**: Set to `false` to prevent all users (including admin) from importing local path on server.
Expand Down Expand Up @@ -1084,6 +1085,7 @@ Task queue configuration has been moved to `queue.task`. However, the below conf
## Federation (`federation`)

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

## Packages (`packages`)

Expand Down
3 changes: 2 additions & 1 deletion docs/content/doc/installation/from-binary.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ Of note, configuring `GITEA_WORK_DIR` will tell Gitea where to base its working

### Prepare environment

Check that Git is installed on the server. If it is not, install it first.
Check that Git is installed on the server. If it is not, install it first. Gitea requires Git version >= 2.0.

```sh
git --version
```
Expand Down
44 changes: 44 additions & 0 deletions docs/content/doc/installation/on-kubernetes.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,47 @@ helm install gitea gitea-charts/gitea
```

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/)

## Health check endpoint

Gitea comes with a health check endpoint `/api/healthz`, you can configure it in kubernetes like this:

```yaml
livenessProbe:
httpGet:
path: /api/healthz
port: http
initialDelaySeconds: 200
timeoutSeconds: 5
periodSeconds: 10
successThreshold: 1
failureThreshold: 10
```
a successful health check response will respond with http code `200`, here's example:

```
HTTP/1.1 200 OK


{
"status": "pass",
"description": "Gitea: Git with a cup of tea",
"checks": {
"cache:ping": [
{
"status": "pass",
"time": "2022-02-19T09:16:08Z"
}
],
"database:ping": [
{
"status": "pass",
"time": "2022-02-19T09:16:08Z"
}
]
}
}
```
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)
Loading

0 comments on commit aca1e3b

Please sign in to comment.