Skip to content

Commit e71f482

Browse files
committed
Merge branch 'master' into new-repo-helper-desc
Signed-off-by: Bagas Sanjaya <[email protected]>
2 parents cdb29d1 + d6068c1 commit e71f482

File tree

460 files changed

+22463
-6871
lines changed

Some content is hidden

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

460 files changed

+22463
-6871
lines changed

.github/issue_template.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
<!-- In addition, if your problem relates to git commands set `RUN_MODE=dev` at the top of app.ini -->
3131

3232
## Description
33+
<!-- If using a proxy or a CDN (e.g. CloudFlare) in front of gitea, please
34+
disable the proxy/CDN fully and connect to gitea directly to confirm
35+
the issue still persists without those services. -->
3336

3437
...
3538

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ help:
190190
go-check:
191191
$(eval GO_VERSION := $(shell printf "%03d%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9.]+' | tr '.' ' ');))
192192
@if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \
193-
echo "Gitea requires Go 1.13 or greater to build. You can get it at https://golang.org/dl/"; \
193+
echo "Gitea requires Go 1.14 or greater to build. You can get it at https://golang.org/dl/"; \
194194
exit 1; \
195195
fi
196196

@@ -573,7 +573,6 @@ release-windows: | $(DIST_DIRS)
573573
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
574574
GO111MODULE=off $(GO) get -u src.techknowlogick.com/xgo; \
575575
fi
576-
@echo "Warning: windows version is built using golang 1.14"
577576
CGO_CFLAGS="$(CGO_CFLAGS)" GO111MODULE=off xgo -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
578577
ifeq ($(CI),drone)
579578
cp /build/* $(DIST)/binaries
@@ -709,7 +708,7 @@ pr\#%: clean-all
709708
golangci-lint:
710709
@hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
711710
export BINARY="golangci-lint"; \
712-
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.35.2; \
711+
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.37.0; \
713712
fi
714713
golangci-lint run --timeout 10m
715714

cmd/dump.go

Lines changed: 24 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -49,38 +49,6 @@ func addFile(w archiver.Writer, filePath string, absPath string, verbose bool) e
4949
})
5050
}
5151

52-
func addRecursive(w archiver.Writer, dirPath string, absPath string, verbose bool) error {
53-
if verbose {
54-
log.Info("Adding dir %s\n", dirPath)
55-
}
56-
dir, err := os.Open(absPath)
57-
if err != nil {
58-
return fmt.Errorf("Could not open directory %s: %s", absPath, err)
59-
}
60-
defer dir.Close()
61-
62-
files, err := dir.Readdir(0)
63-
if err != nil {
64-
return fmt.Errorf("Unable to list files in %s: %s", absPath, err)
65-
}
66-
67-
if err := addFile(w, dirPath, absPath, false); err != nil {
68-
return err
69-
}
70-
71-
for _, fileInfo := range files {
72-
if fileInfo.IsDir() {
73-
err = addRecursive(w, filepath.Join(dirPath, fileInfo.Name()), filepath.Join(absPath, fileInfo.Name()), verbose)
74-
} else {
75-
err = addFile(w, filepath.Join(dirPath, fileInfo.Name()), filepath.Join(absPath, fileInfo.Name()), verbose)
76-
}
77-
if err != nil {
78-
return err
79-
}
80-
}
81-
return nil
82-
}
83-
8452
func isSubdir(upper string, lower string) (bool, error) {
8553
if relPath, err := filepath.Rel(upper, lower); err != nil {
8654
return false, err
@@ -157,6 +125,10 @@ It can be used for backup and capture Gitea server image to send to maintainer`,
157125
Name: "skip-log, L",
158126
Usage: "Skip the log dumping",
159127
},
128+
cli.BoolFlag{
129+
Name: "skip-custom-dir",
130+
Usage: "Skip custom directory",
131+
},
160132
cli.GenericFlag{
161133
Name: "type",
162134
Value: outputTypeEnum,
@@ -211,6 +183,11 @@ func runDump(ctx *cli.Context) error {
211183
}
212184
defer file.Close()
213185

186+
absFileName, err := filepath.Abs(fileName)
187+
if err != nil {
188+
return err
189+
}
190+
214191
verbose := ctx.Bool("verbose")
215192
outType := ctx.String("type")
216193
var iface interface{}
@@ -233,7 +210,7 @@ func runDump(ctx *cli.Context) error {
233210
log.Info("Skip dumping local repositories")
234211
} else {
235212
log.Info("Dumping local repositories... %s", setting.RepoRootPath)
236-
if err := addRecursive(w, "repos", setting.RepoRootPath, verbose); err != nil {
213+
if err := addRecursiveExclude(w, "repos", setting.RepoRootPath, []string{absFileName}, verbose); err != nil {
237214
fatal("Failed to include repositories: %v", err)
238215
}
239216

@@ -292,17 +269,21 @@ func runDump(ctx *cli.Context) error {
292269
}
293270
}
294271

295-
customDir, err := os.Stat(setting.CustomPath)
296-
if err == nil && customDir.IsDir() {
297-
if is, _ := isSubdir(setting.AppDataPath, setting.CustomPath); !is {
298-
if err := addRecursive(w, "custom", setting.CustomPath, verbose); err != nil {
299-
fatal("Failed to include custom: %v", err)
272+
if ctx.IsSet("skip-custom-dir") && ctx.Bool("skip-custom-dir") {
273+
log.Info("Skiping custom directory")
274+
} else {
275+
customDir, err := os.Stat(setting.CustomPath)
276+
if err == nil && customDir.IsDir() {
277+
if is, _ := isSubdir(setting.AppDataPath, setting.CustomPath); !is {
278+
if err := addRecursiveExclude(w, "custom", setting.CustomPath, []string{absFileName}, verbose); err != nil {
279+
fatal("Failed to include custom: %v", err)
280+
}
281+
} else {
282+
log.Info("Custom dir %s is inside data dir %s, skipped", setting.CustomPath, setting.AppDataPath)
300283
}
301284
} else {
302-
log.Info("Custom dir %s is inside data dir %s, skipped", setting.CustomPath, setting.AppDataPath)
285+
log.Info("Custom dir %s doesn't exist, skipped", setting.CustomPath)
303286
}
304-
} else {
305-
log.Info("Custom dir %s doesn't exist, skipped", setting.CustomPath)
306287
}
307288

308289
isExist, err := util.IsExist(setting.AppDataPath)
@@ -325,6 +306,7 @@ func runDump(ctx *cli.Context) error {
325306
excludes = append(excludes, setting.LFS.Path)
326307
excludes = append(excludes, setting.Attachment.Path)
327308
excludes = append(excludes, setting.LogRootPath)
309+
excludes = append(excludes, absFileName)
328310
if err := addRecursiveExclude(w, "data", setting.AppDataPath, excludes, verbose); err != nil {
329311
fatal("Failed to include data directory: %v", err)
330312
}
@@ -358,7 +340,7 @@ func runDump(ctx *cli.Context) error {
358340
log.Error("Unable to check if %s exists. Error: %v", setting.LogRootPath, err)
359341
}
360342
if isExist {
361-
if err := addRecursive(w, "log", setting.LogRootPath, verbose); err != nil {
343+
if err := addRecursiveExclude(w, "log", setting.LogRootPath, []string{absFileName}, verbose); err != nil {
362344
fatal("Failed to include log: %v", err)
363345
}
364346
}

custom/conf/app.example.ini

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,14 +556,16 @@ IMPORT_LOCAL_PATHS = false
556556
; 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.
557557
; WARNING: This maybe harmful to you website or your operating system.
558558
DISABLE_GIT_HOOKS = true
559+
; Set to true to disable webhooks feature.
560+
DISABLE_WEBHOOKS = false
559561
; Set to false to allow pushes to gitea repositories despite having an incomplete environment - NOT RECOMMENDED
560562
ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET = true
561563
;Comma separated list of character classes required to pass minimum complexity.
562564
;If left empty or no valid values are specified, the default is off (no checking)
563565
;Classes include "lower,upper,digit,spec"
564566
PASSWORD_COMPLEXITY = off
565567
; Password Hash algorithm, either "argon2", "pbkdf2", "scrypt" or "bcrypt"
566-
PASSWORD_HASH_ALGO = argon2
568+
PASSWORD_HASH_ALGO = pbkdf2
567569
; Set false to allow JavaScript to read CSRF cookie
568570
CSRF_COOKIE_HTTP_ONLY = true
569571
; Validate against https://haveibeenpwned.com/Passwords to see if a password has been exposed
@@ -615,6 +617,8 @@ REGISTER_MANUAL_CONFIRM = false
615617
; List of domain names that are allowed to be used to register on a Gitea instance
616618
; gitea.io,example.com
617619
EMAIL_DOMAIN_WHITELIST =
620+
; Comma-separated list of domain names that are not allowed to be used to register on a Gitea instance
621+
EMAIL_DOMAIN_BLOCKLIST =
618622
; Disallow registration, only allow admins to create accounts.
619623
DISABLE_REGISTRATION = false
620624
; Allow registration only using third-party services, it works only when DISABLE_REGISTRATION is false

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,12 @@ relation to port exhaustion.
396396
It also enables them to access other resources available to the user on the operating system that is running the
397397
Gitea instance and perform arbitrary actions in the name of the Gitea OS user.
398398
This maybe harmful to you website or your operating system.
399+
- `DISABLE_WEBHOOKS`: **false**: Set to `true` to disable webhooks feature.
399400
- `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.
400401
- `IMPORT_LOCAL_PATHS`: **false**: Set to `false` to prevent all users (including admin) from importing local path on server.
401402
- `INTERNAL_TOKEN`: **\<random at every install if no uri set\>**: Secret used to validate communication within Gitea binary.
402403
- `INTERNAL_TOKEN_URI`: **<empty>**: Instead of defining internal token in the configuration, this configuration option can be used to give Gitea a path to a file that contains the internal token (example value: `file:/etc/gitea/internal_token`)
403-
- `PASSWORD_HASH_ALGO`: **argon2**: The hash algorithm to use \[argon2, pbkdf2, scrypt, bcrypt\].
404+
- `PASSWORD_HASH_ALGO`: **pbkdf2**: The hash algorithm to use \[argon2, pbkdf2, scrypt, bcrypt\], argon2 will spend more memory than others.
404405
- `CSRF_COOKIE_HTTP_ONLY`: **true**: Set false to allow JavaScript to read CSRF cookie.
405406
- `MIN_PASSWORD_LENGTH`: **6**: Minimum password length for new users.
406407
- `PASSWORD_COMPLEXITY`: **off**: Comma separated list of character classes required to pass minimum complexity. If left empty or no valid values are specified, checking is disabled (off):
@@ -465,6 +466,7 @@ relation to port exhaustion.
465466
- `DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME`: **true**: Only allow users with write permissions to track time.
466467
- `EMAIL_DOMAIN_WHITELIST`: **\<empty\>**: If non-empty, list of domain names that can only be used to register
467468
on this instance.
469+
- `EMAIL_DOMAIN_BLOCKLIST`: **\<empty\>**: If non-empty, list of domain names that cannot be used to register on this instance
468470
- `SHOW_REGISTRATION_BUTTON`: **! DISABLE\_REGISTRATION**: Show Registration Button
469471
- `SHOW_MILESTONES_DASHBOARD_PAGE`: **true** Enable this to show the milestones dashboard page - a view of all the user's milestones
470472
- `AUTO_WATCH_NEW_REPOS`: **true**: Enable this to let all organisation users watch new repos when they are created
@@ -549,7 +551,7 @@ Define allowed algorithms and their minimum key length (use -1 to disable a type
549551

550552
## Session (`session`)
551553

552-
- `PROVIDER`: **memory**: Session engine provider \[memory, file, redis, mysql, couchbase, memcache, postgres\].
554+
- `PROVIDER`: **memory**: Session engine provider \[memory, file, redis, db, mysql, couchbase, memcache, postgres\].
553555
- `PROVIDER_CONFIG`: **data/sessions**: For file, the root path; for others, the connection string.
554556
- `COOKIE_SECURE`: **false**: Enable this to force using HTTPS for all session access.
555557
- `COOKIE_NAME`: **i\_like\_gitea**: The name of the cookie used for the session ID.

docs/content/doc/help/faq.en-us.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,14 @@ For more information, refer to Gitea's [API docs]({{< relref "doc/developers/api
120120

121121
There are multiple things you can combine to prevent spammers.
122122

123-
1. By only whitelisting certain domains with OpenID (see below)
124-
2. Setting `ENABLE_CAPTCHA` to `true` in your `app.ini` and properly configuring `RECAPTCHA_SECRET` and `RECAPTCHA_SITEKEY`
125-
3. Settings `DISABLE_REGISTRATION` to `true` and creating new users via the [CLI]({{< relref "doc/usage/command-line.en-us.md" >}}), [API]({{< relref "doc/developers/api-usage.en-us.md" >}}), or Gitea's Admin UI
123+
1. By whitelisting or blocklisting certain email domains
124+
2. By only whitelisting certain domains with OpenID (see below)
125+
3. Setting `ENABLE_CAPTCHA` to `true` in your `app.ini` and properly configuring `RECAPTCHA_SECRET` and `RECAPTCHA_SITEKEY`
126+
4. Settings `DISABLE_REGISTRATION` to `true` and creating new users via the [CLI]({{< relref "doc/usage/command-line.en-us.md" >}}), [API]({{< relref "doc/developers/api-usage.en-us.md" >}}), or Gitea's Admin UI
126127

127-
### Only allow certain email domains
128+
### Only allow/block certain email domains
128129

129-
You can configure `EMAIL_DOMAIN_WHITELIST` in your app.ini under `[service]`
130+
You can configure `EMAIL_DOMAIN_WHITELIST` or `EMAIL_DOMAIN_BLOCKLIST` in your app.ini under `[service]`
130131

131132
### Only allow/block certain OpenID providers
132133

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,11 @@ CC=aarch64-unknown-linux-gnu-gcc GOOS=linux GOARCH=arm64 TAGS="bindata sqlite sq
186186
```
187187

188188
Replace `CC`, `GOOS`, and `GOARCH` as appropriate for your architecture target.
189+
190+
You will sometimes need to build a static compiled image. To do this you will need to add:
191+
192+
```
193+
LDFLAGS="-linkmode external -extldflags '-static' $LDFLAGS" TAGS="netgo osusergo $TAGS" make build
194+
```
195+
196+
This can be combined with `CC`, `GOOS`, and `GOARCH` as above.

docs/content/doc/usage/command-line.en-us.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ Generates a self-signed SSL certificate. Outputs to `cert.pem` and `key.pem` in
232232
directory and will overwrite any existing files.
233233

234234
- Options:
235-
- `--host value`: Comma seperated hostnames and ips which this certificate is valid for.
235+
- `--host value`: Comma separated hostnames and ips which this certificate is valid for.
236236
Wildcards are supported. Required.
237237
- `--ecdsa-curve value`: ECDSA curve to use to generate a key. Optional. Valid options
238238
are P224, P256, P384, P521.
@@ -253,6 +253,7 @@ in the current directory.
253253
- `--file name`, `-f name`: Name of the dump file with will be created. Optional. (default: gitea-dump-[timestamp].zip).
254254
- `--tempdir path`, `-t path`: Path to the temporary directory used. Optional. (default: /tmp).
255255
- `--skip-repository`, `-R`: Skip the repository dumping. Optional.
256+
- `--skip-custom-dir`: Skip dumping of the custom dir. Optional.
256257
- `--database`, `-d`: Specify the database SQL syntax. Optional.
257258
- `--verbose`, `-V`: If provided, shows additional details. Optional.
258259
- Examples:

go.mod

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ require (
3535
github.com/go-git/go-billy/v5 v5.0.0
3636
github.com/go-git/go-git/v5 v5.2.0
3737
github.com/go-ldap/ldap/v3 v3.2.4
38-
github.com/go-redis/redis/v7 v7.4.0
38+
github.com/go-redis/redis/v8 v8.5.0
3939
github.com/go-sql-driver/mysql v1.5.0
4040
github.com/go-swagger/go-swagger v0.26.0
4141
github.com/go-testfixtures/testfixtures/v3 v3.4.1
@@ -46,6 +46,8 @@ require (
4646
github.com/google/go-github/v32 v32.1.0
4747
github.com/google/uuid v1.2.0
4848
github.com/gorilla/context v1.1.1
49+
github.com/gorilla/sessions v1.2.1 // indirect
50+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
4951
github.com/hashicorp/go-retryablehttp v0.6.8 // indirect
5052
github.com/hashicorp/go-version v1.2.1
5153
github.com/huandu/xstrings v1.3.2
@@ -57,7 +59,7 @@ require (
5759
github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4
5860
github.com/klauspost/compress v1.11.7
5961
github.com/klauspost/pgzip v1.2.5 // indirect
60-
github.com/lafriks/xormstore v1.3.2
62+
github.com/lafriks/xormstore v1.4.0
6163
github.com/lib/pq v1.9.0
6264
github.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96
6365
github.com/markbates/goth v1.66.1
@@ -69,7 +71,7 @@ require (
6971
github.com/mholt/archiver/v3 v3.5.0
7072
github.com/microcosm-cc/bluemonday v1.0.4
7173
github.com/minio/md5-simd v1.1.1 // indirect
72-
github.com/minio/minio-go/v7 v7.0.7
74+
github.com/minio/minio-go/v7 v7.0.9
7375
github.com/mitchellh/go-homedir v1.1.0
7476
github.com/msteinert/pam v0.0.0-20200810204841-913b8f8cdf8b
7577
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
@@ -80,7 +82,7 @@ require (
8082
github.com/pierrec/lz4/v4 v4.1.1 // indirect
8183
github.com/pkg/errors v0.9.1
8284
github.com/pquerna/otp v1.3.0
83-
github.com/prometheus/client_golang v1.8.0
85+
github.com/prometheus/client_golang v1.9.0
8486
github.com/quasoft/websspi v1.0.0
8587
github.com/rivo/uniseg v0.2.0 // indirect
8688
github.com/sergi/go-diff v1.1.0
@@ -98,16 +100,16 @@ require (
98100
github.com/unrolled/render v1.0.3
99101
github.com/urfave/cli v1.22.5
100102
github.com/willf/bitset v1.1.11 // indirect
101-
github.com/xanzy/go-gitlab v0.42.0
103+
github.com/xanzy/go-gitlab v0.44.0
102104
github.com/yohcop/openid-go v1.0.0
103-
github.com/yuin/goldmark v1.3.1
105+
github.com/yuin/goldmark v1.3.2
104106
github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691
105107
github.com/yuin/goldmark-meta v1.0.0
106108
go.jolheiser.com/hcaptcha v0.0.4
107109
go.jolheiser.com/pwn v0.0.3
108110
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
109111
golang.org/x/net v0.0.0-20210119194325-5f4716e94777
110-
golang.org/x/oauth2 v0.0.0-20210126194326-f9ce19ea3013
112+
golang.org/x/oauth2 v0.0.0-20210210192628-66670185b0cd
111113
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
112114
golang.org/x/text v0.3.5
113115
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
@@ -118,8 +120,8 @@ require (
118120
gopkg.in/yaml.v2 v2.4.0
119121
mvdan.cc/xurls/v2 v2.2.0
120122
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
121-
xorm.io/builder v0.3.7
122-
xorm.io/xorm v1.0.6
123+
xorm.io/builder v0.3.9
124+
xorm.io/xorm v1.0.7
123125
)
124126

125127
replace github.com/hashicorp/go-version => github.com/6543/go-version v1.2.4

0 commit comments

Comments
 (0)