Skip to content

Commit 123b8c6

Browse files
authored
Merge branch 'master' into default-board
2 parents 7184ad8 + f76c300 commit 123b8c6

File tree

69 files changed

+1266
-193
lines changed

Some content is hidden

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

69 files changed

+1266
-193
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
open_collective: gitea
2+
custom: https://www.bountysource.com/teams/gitea

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
<a href="https://www.tickgit.com/browse?repo=github.com/go-gitea/gitea" title="TODOs">
4343
<img src="https://badgen.net/https/api.tickgit.com/badgen/github.com/go-gitea/gitea">
4444
</a>
45+
<a href="https://www.bountysource.com/teams/gitea" title="Bountysource">
46+
<img src="https://img.shields.io/bountysource/team/gitea/activity">
47+
</a>
4548
</p>
4649

4750
<p align="center">

README_ZH.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
<a href="https://www.tickgit.com/browse?repo=github.com/go-gitea/gitea" title="TODOs">
4343
<img src="https://badgen.net/https/api.tickgit.com/badgen/github.com/go-gitea/gitea">
4444
</a>
45+
<a href="https://img.shields.io/bountysource/team/gitea" title="Bountysource">
46+
<img src="https://img.shields.io/bountysource/team/gitea/activity">
47+
</a>
4548
</p>
4649

4750
<p align="center">

custom/conf/app.example.ini

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
; This file lists the default values used by Gitea
22
; Copy required sections to your own app.ini (default is custom/conf/app.ini)
33
; and modify as needed.
4+
; Do not copy the whole file as-is, as it contains some invalid sections for illustrative purposes.
5+
; If you don't know what a setting is you should not set it.
46

57
; see https://docs.gitea.io/en-us/config-cheat-sheet/ for additional documentation.
68

@@ -242,6 +244,10 @@ TIMEOUT_STEP = 10s
242244
; If the browser client supports EventSource and SharedWorker, a SharedWorker will be used in preference to polling notification. Set to -1 to disable the EventSource
243245
EVENT_SOURCE_UPDATE_TIME = 10s
244246

247+
[ui.svg]
248+
; Whether to render SVG files as images. If SVG rendering is disabled, SVG files are displayed as text and cannot be embedded in markdown files as images.
249+
ENABLE_RENDER = true
250+
245251
[markdown]
246252
; Render soft line breaks as hard line breaks, which means a single newline character between
247253
; paragraphs will cause a line break and adding trailing whitespace to paragraphs is not
@@ -451,10 +457,13 @@ ISSUE_INDEXER_NAME = gitea_issues
451457
ISSUE_INDEXER_PATH = indexers/issues.bleve
452458
; Issue indexer queue, currently support: channel, levelqueue or redis, default is levelqueue
453459
ISSUE_INDEXER_QUEUE_TYPE = levelqueue
454-
; When ISSUE_INDEXER_QUEUE_TYPE is levelqueue, this will be the queue will be saved path,
460+
; When ISSUE_INDEXER_QUEUE_TYPE is levelqueue, this will be the path where the queue will be saved.
461+
; This can be overriden by `ISSUE_INDEXER_QUEUE_CONN_STR`.
455462
; default is indexers/issues.queue
456463
ISSUE_INDEXER_QUEUE_DIR = indexers/issues.queue
457464
; When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string.
465+
; When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this is a directory or additional options of
466+
; the form `leveldb://path/to/db?option=value&....`, and overrides `ISSUE_INDEXER_QUEUE_DIR`.
458467
ISSUE_INDEXER_QUEUE_CONN_STR = "addrs=127.0.0.1:6379 db=0"
459468
; Batch queue number, default is 20
460469
ISSUE_INDEXER_QUEUE_BATCH_NUMBER = 20
@@ -494,6 +503,8 @@ LENGTH = 20
494503
; Batch size to send for batched queues
495504
BATCH_LENGTH = 20
496505
; Connection string for redis queues this will store the redis connection string.
506+
; When `TYPE` is `persistable-channel`, this provides a directory for the underlying leveldb
507+
; or additional options of the form `leveldb://path/to/db?option=value&....`, and will override `DATADIR`.
497508
CONN_STR = "addrs=127.0.0.1:6379 db=0"
498509
; Provides the suffix of the default redis/disk queue name - specific queues can be overriden within in their [queue.name] sections.
499510
QUEUE_NAME = "_queue"
@@ -856,7 +867,7 @@ MACARON = file
856867
ROUTER_LOG_LEVEL = Info
857868
ROUTER = console
858869
ENABLE_ACCESS_LOG = false
859-
ACCESS_LOG_TEMPLATE = {{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}"
870+
ACCESS_LOG_TEMPLATE = {{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}"
860871
ACCESS = file
861872
; Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Trace"
862873
LEVEL = Info

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
194194
- `TIMEOUT_STEP`: **10s**.
195195
- `EVENT_SOURCE_UPDATE_TIME`: **10s**: This setting determines how often the database is queried to update notification counts. If the browser client supports `EventSource` and `SharedWorker`, a `SharedWorker` will be used in preference to polling notification endpoint. Set to **-1** to disable the `EventSource`.
196196

197+
### UI - SVG Images (`ui.svg`)
198+
199+
- `ENABLE_RENDER`: **true**: Whether to render SVG files as images. If SVG rendering is disabled, SVG files are displayed as text and cannot be embedded in markdown files as images.
200+
197201
## Markdown (`markdown`)
198202

199203
- `ENABLE_HARD_LINE_BREAK_IN_COMMENTS`: **true**: Render soft line breaks as hard line breaks in comments, which
@@ -331,8 +335,8 @@ relation to port exhaustion.
331335
- `ISSUE_INDEXER_PATH`: **indexers/issues.bleve**: Index file used for issue search; available when ISSUE_INDEXER_TYPE is bleve and elasticsearch.
332336
- The next 4 configuration values are deprecated and should be set in `queue.issue_indexer` however are kept for backwards compatibility:
333337
- `ISSUE_INDEXER_QUEUE_TYPE`: **levelqueue**: Issue indexer queue, currently supports:`channel`, `levelqueue`, `redis`.
334-
- `ISSUE_INDEXER_QUEUE_DIR`: **indexers/issues.queue**: When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this will be the queue will be saved path.
335-
- `ISSUE_INDEXER_QUEUE_CONN_STR`: **addrs=127.0.0.1:6379 db=0**: When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string.
338+
- `ISSUE_INDEXER_QUEUE_DIR`: **indexers/issues.queue**: When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this will be the path where the queue will be saved.
339+
- `ISSUE_INDEXER_QUEUE_CONN_STR`: **addrs=127.0.0.1:6379 db=0**: When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string. When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this is a directory or additional options of the form `leveldb://path/to/db?option=value&....`, and overrides `ISSUE_INDEXER_QUEUE_DIR`.
336340
- `ISSUE_INDEXER_QUEUE_BATCH_NUMBER`: **20**: Batch queue number.
337341

338342
- `REPO_INDEXER_ENABLED`: **false**: Enables code search (uses a lot of disk space, about 6 times more than the repository size).
@@ -350,11 +354,11 @@ relation to port exhaustion.
350354

351355
## Queue (`queue` and `queue.*`)
352356

353-
- `TYPE`: **persistable-channel**: General queue type, currently support: `persistable-channel`, `channel`, `level`, `redis`, `dummy`
357+
- `TYPE`: **persistable-channel**: General queue type, currently support: `persistable-channel` (uses a LevelDB internally), `channel`, `level`, `redis`, `dummy`
354358
- `DATADIR`: **queues/**: Base DataDir for storing persistent and level queues. `DATADIR` for individual queues can be set in `queue.name` sections but will default to `DATADIR/`**`name`**.
355359
- `LENGTH`: **20**: Maximal queue size before channel queues block
356360
- `BATCH_LENGTH`: **20**: Batch data before passing to the handler
357-
- `CONN_STR`: **redis://127.0.0.1:6379/0**: Connection string for the redis queue type. Options can be set using query params. Similarly LevelDB options can also be set using: **leveldb://relative/path?option=value** or **leveldb:///absolute/path?option=value**
361+
- `CONN_STR`: **redis://127.0.0.1:6379/0**: Connection string for the redis queue type. Options can be set using query params. Similarly LevelDB options can also be set using: **leveldb://relative/path?option=value** or **leveldb:///absolute/path?option=value**, and will override `DATADIR`
358362
- `QUEUE_NAME`: **_queue**: The suffix for default redis and disk queue name. Individual queues will default to **`name`**`QUEUE_NAME` but can be overriden in the specific `queue.name` section.
359363
- `SET_NAME`: **_unique**: The suffix that will be added to the default redis and disk queue `set` name for unique queues. Individual queues will default to
360364
**`name`**`QUEUE_NAME`_`SET_NAME`_ but can be overridden in the specific `queue.name` section.

integrations/api_issue_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,15 @@ func TestAPISearchIssues(t *testing.T) {
186186
req = NewRequest(t, "GET", link.String())
187187
resp = session.MakeRequest(t, req, http.StatusOK)
188188
DecodeJSON(t, resp, &apiIssues)
189-
assert.EqualValues(t, "12", resp.Header().Get("X-Total-Count"))
189+
assert.EqualValues(t, "14", resp.Header().Get("X-Total-Count"))
190190
assert.Len(t, apiIssues, 10) //there are more but 10 is page item limit
191191

192192
query.Add("limit", "20")
193193
link.RawQuery = query.Encode()
194194
req = NewRequest(t, "GET", link.String())
195195
resp = session.MakeRequest(t, req, http.StatusOK)
196196
DecodeJSON(t, resp, &apiIssues)
197-
assert.Len(t, apiIssues, 12)
197+
assert.Len(t, apiIssues, 14)
198198

199199
query = url.Values{"assigned": {"true"}, "state": {"all"}}
200200
link.RawQuery = query.Encode()

integrations/api_repo_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ func TestAPISearchRepo(t *testing.T) {
7777
expectedResults
7878
}{
7979
{name: "RepositoriesMax50", requestURL: "/api/v1/repos/search?limit=50&private=false", expectedResults: expectedResults{
80-
nil: {count: 28},
81-
user: {count: 28},
82-
user2: {count: 28}},
80+
nil: {count: 30},
81+
user: {count: 30},
82+
user2: {count: 30}},
8383
},
8484
{name: "RepositoriesMax10", requestURL: "/api/v1/repos/search?limit=10&private=false", expectedResults: expectedResults{
8585
nil: {count: 10},

integrations/download_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@ func TestDownloadByID(t *testing.T) {
2323
assert.Equal(t, "# repo1\n\nDescription for repo1", resp.Body.String())
2424
}
2525

26+
func TestDownloadByIDForSVGUsesSecureHeaders(t *testing.T) {
27+
defer prepareTestEnv(t)()
28+
29+
session := loginUser(t, "user2")
30+
31+
// Request raw blob
32+
req := NewRequest(t, "GET", "/user2/repo2/raw/blob/6395b68e1feebb1e4c657b4f9f6ba2676a283c0b")
33+
resp := session.MakeRequest(t, req, http.StatusOK)
34+
35+
assert.Equal(t, "default-src 'none'; style-src 'unsafe-inline'; sandbox", resp.HeaderMap.Get("Content-Security-Policy"))
36+
assert.Equal(t, "image/svg+xml", resp.HeaderMap.Get("Content-Type"))
37+
assert.Equal(t, "nosniff", resp.HeaderMap.Get("X-Content-Type-Options"))
38+
}
39+
2640
func TestDownloadByIDMedia(t *testing.T) {
2741
defer prepareTestEnv(t)()
2842

@@ -34,3 +48,17 @@ func TestDownloadByIDMedia(t *testing.T) {
3448

3549
assert.Equal(t, "# repo1\n\nDescription for repo1", resp.Body.String())
3650
}
51+
52+
func TestDownloadByIDMediaForSVGUsesSecureHeaders(t *testing.T) {
53+
defer prepareTestEnv(t)()
54+
55+
session := loginUser(t, "user2")
56+
57+
// Request raw blob
58+
req := NewRequest(t, "GET", "/user2/repo2/media/blob/6395b68e1feebb1e4c657b4f9f6ba2676a283c0b")
59+
resp := session.MakeRequest(t, req, http.StatusOK)
60+
61+
assert.Equal(t, "default-src 'none'; style-src 'unsafe-inline'; sandbox", resp.HeaderMap.Get("Content-Security-Policy"))
62+
assert.Equal(t, "image/svg+xml", resp.HeaderMap.Get("Content-Type"))
63+
assert.Equal(t, "nosniff", resp.HeaderMap.Get("X-Content-Type-Options"))
64+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref: refs/heads/master
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[core]
2+
repositoryformatversion = 0
3+
filemode = true
4+
bare = true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Unnamed repository; edit this file 'description' to name the repository.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
#
3+
# An example hook script to check the commit log message taken by
4+
# applypatch from an e-mail message.
5+
#
6+
# The hook should exit with non-zero status after issuing an
7+
# appropriate message if it wants to stop the commit. The hook is
8+
# allowed to edit the commit message file.
9+
#
10+
# To enable this hook, rename this file to "applypatch-msg".
11+
12+
. git-sh-setup
13+
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
14+
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
15+
:
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
#
3+
# An example hook script to check the commit log message.
4+
# Called by "git commit" with one argument, the name of the file
5+
# that has the commit message. The hook should exit with non-zero
6+
# status after issuing an appropriate message if it wants to stop the
7+
# commit. The hook is allowed to edit the commit message file.
8+
#
9+
# To enable this hook, rename this file to "commit-msg".
10+
11+
# Uncomment the below to add a Signed-off-by line to the message.
12+
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
13+
# hook is more suited to it.
14+
#
15+
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
16+
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
17+
18+
# This example catches duplicate Signed-off-by lines.
19+
20+
test "" = "$(grep '^Signed-off-by: ' "$1" |
21+
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
22+
echo >&2 Duplicate Signed-off-by lines.
23+
exit 1
24+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
#
3+
# An example hook script to prepare a packed repository for use over
4+
# dumb transports.
5+
#
6+
# To enable this hook, rename this file to "post-update".
7+
8+
exec git update-server-info
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
#
3+
# An example hook script to verify what is about to be committed
4+
# by applypatch from an e-mail message.
5+
#
6+
# The hook should exit with non-zero status after issuing an
7+
# appropriate message if it wants to stop the commit.
8+
#
9+
# To enable this hook, rename this file to "pre-applypatch".
10+
11+
. git-sh-setup
12+
precommit="$(git rev-parse --git-path hooks/pre-commit)"
13+
test -x "$precommit" && exec "$precommit" ${1+"$@"}
14+
:
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/sh
2+
#
3+
# An example hook script to verify what is about to be committed.
4+
# Called by "git commit" with no arguments. The hook should
5+
# exit with non-zero status after issuing an appropriate message if
6+
# it wants to stop the commit.
7+
#
8+
# To enable this hook, rename this file to "pre-commit".
9+
10+
if git rev-parse --verify HEAD >/dev/null 2>&1
11+
then
12+
against=HEAD
13+
else
14+
# Initial commit: diff against an empty tree object
15+
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
16+
fi
17+
18+
# If you want to allow non-ASCII filenames set this variable to true.
19+
allownonascii=$(git config --bool hooks.allownonascii)
20+
21+
# Redirect output to stderr.
22+
exec 1>&2
23+
24+
# Cross platform projects tend to avoid non-ASCII filenames; prevent
25+
# them from being added to the repository. We exploit the fact that the
26+
# printable range starts at the space character and ends with tilde.
27+
if [ "$allownonascii" != "true" ] &&
28+
# Note that the use of brackets around a tr range is ok here, (it's
29+
# even required, for portability to Solaris 10's /usr/bin/tr), since
30+
# the square bracket bytes happen to fall in the designated range.
31+
test $(git diff --cached --name-only --diff-filter=A -z $against |
32+
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
33+
then
34+
cat <<\EOF
35+
Error: Attempt to add a non-ASCII file name.
36+
37+
This can cause problems if you want to work with people on other platforms.
38+
39+
To be portable it is advisable to rename the file.
40+
41+
If you know what you are doing you can disable this check using:
42+
43+
git config hooks.allownonascii true
44+
EOF
45+
exit 1
46+
fi
47+
48+
# If there are whitespace errors, print the offending file names and fail.
49+
exec git diff-index --check --cached $against --
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/sh
2+
3+
# An example hook script to verify what is about to be pushed. Called by "git
4+
# push" after it has checked the remote status, but before anything has been
5+
# pushed. If this script exits with a non-zero status nothing will be pushed.
6+
#
7+
# This hook is called with the following parameters:
8+
#
9+
# $1 -- Name of the remote to which the push is being done
10+
# $2 -- URL to which the push is being done
11+
#
12+
# If pushing without using a named remote those arguments will be equal.
13+
#
14+
# Information about the commits which are being pushed is supplied as lines to
15+
# the standard input in the form:
16+
#
17+
# <local ref> <local sha1> <remote ref> <remote sha1>
18+
#
19+
# This sample shows how to prevent push of commits where the log message starts
20+
# with "WIP" (work in progress).
21+
22+
remote="$1"
23+
url="$2"
24+
25+
z40=0000000000000000000000000000000000000000
26+
27+
while read local_ref local_sha remote_ref remote_sha
28+
do
29+
if [ "$local_sha" = $z40 ]
30+
then
31+
# Handle delete
32+
:
33+
else
34+
if [ "$remote_sha" = $z40 ]
35+
then
36+
# New branch, examine all commits
37+
range="$local_sha"
38+
else
39+
# Update to existing branch, examine new commits
40+
range="$remote_sha..$local_sha"
41+
fi
42+
43+
# Check for WIP commit
44+
commit=`git rev-list -n 1 --grep '^WIP' "$range"`
45+
if [ -n "$commit" ]
46+
then
47+
echo >&2 "Found WIP commit in $local_ref, not pushing"
48+
exit 1
49+
fi
50+
fi
51+
done
52+
53+
exit 0

0 commit comments

Comments
 (0)