Skip to content

Commit 9212acc

Browse files
committed
Merge branch 'master' into open-repository-open-cat-file-batch
2 parents 5317d34 + 0590176 commit 9212acc

Some content is hidden

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

48 files changed

+466
-163
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ RUN addgroup \
5353
-u 1000 \
5454
-G git \
5555
git && \
56-
echo "git:$(dd if=/dev/urandom bs=24 count=1 status=none | base64)" | chpasswd
56+
echo "git:*" | chpasswd -e
5757

5858
ENV USER git
5959
ENV GITEA_CUSTOM /data/gitea

Dockerfile.rootless

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ RUN addgroup \
4646
-s /bin/bash \
4747
-u 1000 \
4848
-G git \
49-
git && \
50-
echo "git:$(dd if=/dev/urandom bs=24 count=1 status=none | base64)" | chpasswd
49+
git
5150

5251
RUN mkdir -p /var/lib/gitea /etc/gitea
5352
RUN chown git:git /var/lib/gitea /etc/gitea

custom/conf/app.example.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,14 @@ RUN_AT_START = false
11451145
NO_SUCCESS_NOTICE = false
11461146
SCHEDULE = @every 72h
11471147

1148+
; Delete all old actions from database
1149+
[cron.delete_old_actions]
1150+
ENABLED = false
1151+
RUN_AT_START = false
1152+
NO_SUCCESS_NOTICE = false
1153+
SCHEDULE = @every 168h
1154+
OLDER_THAN = 8760h
1155+
11481156
[git]
11491157
; The path of git executable. If empty, Gitea searches through the PATH environment.
11501158
PATH =

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
5959
- `MIRROR_QUEUE_LENGTH`: **1000**: Patch test queue length, increase if pull request patch
6060
testing starts hanging.
6161
- `PREFERRED_LICENSES`: **Apache License 2.0,MIT License**: Preferred Licenses to place at
62-
the top of the list. Name must match file name in conf/license or custom/conf/license.
62+
the top of the list. Name must match file name in options/license or custom/options/license.
6363
- `DISABLE_HTTP_GIT`: **false**: Disable the ability to interact with repositories over the
6464
HTTP protocol.
6565
- `USE_COMPAT_SSH_URI`: **false**: Force ssh:// clone url instead of scp-style uri when
@@ -786,6 +786,13 @@ NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take ef
786786
- `NO_SUCCESS_NOTICE`: **false**: Set to true to switch off success notices.
787787
- `SCHEDULE`: **@every 72h**: Cron syntax for scheduling repository archive cleanup, e.g. `@every 1h`.
788788

789+
#### Cron - Delete all old actions from database ('cron.delete_old_actions')
790+
- `ENABLED`: **false**: Enable service.
791+
- `RUN_AT_START`: **false**: Run tasks at start up time (if ENABLED).
792+
- `NO_SUCCESS_NOTICE`: **false**: Set to true to switch off success notices.
793+
- `SCHEDULE`: **@every 128h**: Cron syntax for scheduling a work, e.g. `@every 128h`.
794+
- `OLDER_THAN`: **@every 8760h**: any action older than this expression will be deleted from database, suggest using `8760h` (1 year) because that's the max length of heatmap.
795+
789796
## Git (`git`)
790797

791798
- `PATH`: **""**: The path of git executable. If empty, Gitea searches through the PATH environment.

docs/content/doc/advanced/external-renderers.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ IS_INPUT_FILE = true
7070
[markup.restructuredtext]
7171
ENABLED = true
7272
FILE_EXTENSIONS = .rst
73-
RENDER_COMMAND = rst2html.py
73+
RENDER_COMMAND = "timeout 30s pandoc +RTS -M512M -RTS -f rst"
7474
IS_INPUT_FILE = false
7575
```
7676

integrations/mssql.ini.tmpl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ PASSWD = {{TEST_MSSQL_PASSWORD}}
1010
SSL_MODE = disable
1111

1212
[indexer]
13-
ISSUE_INDEXER_PATH = integrations/indexers-mssql/issues.bleve
13+
ISSUE_INDEXER_PATH = integrations/gitea-integration-mssql/indexers/issues.bleve
14+
ISSUE_INDEXER_QUEUE_DIR = integrations/gitea-integration-mssql/indexers/issues.queue
1415
REPO_INDEXER_ENABLED = true
15-
REPO_INDEXER_PATH = integrations/indexers-mssql/repos.bleve
16+
REPO_INDEXER_PATH = integrations/gitea-integration-mssql/indexers/repos.bleve
1617

1718
[queue.code_indexer]
1819
TYPE = immediate
@@ -24,8 +25,10 @@ TYPE = immediate
2425
ROOT = {{REPO_TEST_DIR}}integrations/gitea-integration-mssql/gitea-repositories
2526

2627
[repository.local]
27-
LOCAL_COPY_PATH = tmp/local-repo-mssql
28-
LOCAL_WIKI_PATH = tmp/local-wiki-mssql
28+
LOCAL_COPY_PATH = integrations/gitea-integration-mssql/tmp/local-repo
29+
30+
[repository.upload]
31+
TEMP_PATH = integrations/gitea-integration-mssql/tmp/uploads
2932

3033
[repository.signing]
3134
SIGNING_KEY = none
@@ -39,14 +42,14 @@ SSH_LISTEN_HOST = localhost
3942
SSH_PORT = 2201
4043
START_SSH_SERVER = true
4144
LFS_START_SERVER = true
42-
LFS_CONTENT_PATH = integrations/gitea-integration-mssql/data/lfs-mssql
45+
LFS_CONTENT_PATH = integrations/gitea-integration-mssql/data/lfs
4346
OFFLINE_MODE = false
4447
LFS_JWT_SECRET = Tv_MjmZuHqpIY6GFl12ebgkRAMt4RlWt0v4EHKSXO0w
4548
APP_DATA_PATH = integrations/gitea-integration-mssql/data
4649
BUILTIN_SSH_SERVER_USER = git
4750

4851
[attachment]
49-
PATH = integrations/gitea-integration-mssql/data
52+
PATH = integrations/gitea-integration-mssql/data/attachments
5053

5154
[mailer]
5255
ENABLED = true

integrations/mysql.ini.tmpl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ SSL_MODE = disable
1212
[indexer]
1313
ISSUE_INDEXER_TYPE = elasticsearch
1414
ISSUE_INDEXER_CONN_STR = http://elastic:changeme@elasticsearch:9200
15-
ISSUE_INDEXER_PATH = integrations/indexers-mysql/issues.bleve
15+
ISSUE_INDEXER_QUEUE_DIR = integrations/gitea-integration-mysql/indexers/issues.queue
1616
REPO_INDEXER_ENABLED = true
17-
REPO_INDEXER_PATH = integrations/indexers-mysql/repos.bleve
17+
REPO_INDEXER_PATH = integrations/gitea-integration-mysql/indexers/repos.bleve
1818

1919
[queue.code_indexer]
2020
TYPE = immediate
@@ -26,8 +26,10 @@ TYPE = immediate
2626
ROOT = {{REPO_TEST_DIR}}integrations/gitea-integration-mysql/gitea-repositories
2727

2828
[repository.local]
29-
LOCAL_COPY_PATH = tmp/local-repo-mysql
30-
LOCAL_WIKI_PATH = tmp/local-wiki-mysql
29+
LOCAL_COPY_PATH = integrations/gitea-integration-mysql/tmp/local-repo
30+
31+
[repository.upload]
32+
TEMP_PATH = integrations/gitea-integration-mysql/tmp/uploads
3133

3234
[repository.signing]
3335
SIGNING_KEY = none

integrations/mysql8.ini.tmpl

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ PASSWD = {{TEST_MYSQL8_PASSWORD}}
1010
SSL_MODE = disable
1111

1212
[indexer]
13-
ISSUE_INDEXER_PATH = integrations/indexers-mysql8/issues.bleve
13+
ISSUE_INDEXER_PATH = integrations/gitea-integration-mysql8/indexers/issues.bleve
14+
ISSUE_INDEXER_QUEUE_DIR = integrations/gitea-integration-mysql8/indexers/issues.queue
1415
REPO_INDEXER_ENABLED = true
15-
REPO_INDEXER_PATH = integrations/indexers-mysql8/repos.bleve
16+
REPO_INDEXER_PATH = integrations/gitea-integration-mysql8/indexers/repos.bleve
1617

1718
[queue.code_indexer]
1819
TYPE = immediate
@@ -24,8 +25,10 @@ TYPE = immediate
2425
ROOT = {{REPO_TEST_DIR}}integrations/gitea-integration-mysql8/gitea-repositories
2526

2627
[repository.local]
27-
LOCAL_COPY_PATH = tmp/local-repo-mysql8
28-
LOCAL_WIKI_PATH = tmp/local-wiki-mysql8
28+
LOCAL_COPY_PATH = integrations/gitea-integration-mysql8/tmp/local-repo
29+
30+
[repository.upload]
31+
TEMP_PATH = integrations/gitea-integration-mysql8/tmp/uploads
2932

3033
[repository.signing]
3134
SIGNING_KEY = none
@@ -39,12 +42,15 @@ SSH_LISTEN_HOST = localhost
3942
SSH_PORT = 2204
4043
START_SSH_SERVER = true
4144
LFS_START_SERVER = true
42-
LFS_CONTENT_PATH = data/lfs-mysql8
45+
LFS_CONTENT_PATH = integrations/gitea-integration-mysql8/data/lfs
4346
OFFLINE_MODE = false
4447
LFS_JWT_SECRET = Tv_MjmZuHqpIY6GFl12ebgkRAMt4RlWt0v4EHKSXO0w
4548
APP_DATA_PATH = integrations/gitea-integration-mysql8/data
4649
BUILTIN_SSH_SERVER_USER = git
4750

51+
[attachment]
52+
PATH = integrations/gitea-integration-mysql8/data/attachments
53+
4854
[mailer]
4955
ENABLED = false
5056

@@ -60,12 +66,14 @@ DEFAULT_ALLOW_CREATE_ORGANIZATION = true
6066
NO_REPLY_ADDRESS = noreply.example.org
6167

6268
[picture]
63-
DISABLE_GRAVATAR = false
64-
ENABLE_FEDERATED_AVATAR = false
69+
DISABLE_GRAVATAR = false
70+
ENABLE_FEDERATED_AVATAR = false
71+
AVATAR_UPLOAD_PATH = integrations/gitea-integration-mysql8/data/avatars
72+
REPOSITORY_AVATAR_UPLOAD_PATH = integrations/gitea-integration-mysql8/data/repo-avatars
6573

6674
[session]
6775
PROVIDER = file
68-
PROVIDER_CONFIG = data/sessions-mysql8
76+
PROVIDER_CONFIG = integrations/gitea-integration-mysql8/data/sessions
6977

7078
[log]
7179
MODE = test,file
@@ -80,10 +88,8 @@ COLORIZE = true
8088
[log.file]
8189
LEVEL = Debug
8290

83-
8491
[security]
8592
DISABLE_GIT_HOOKS = false
8693
INSTALL_LOCK = true
8794
SECRET_KEY = 9pCviYTWSb
8895
INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.hhSVGOANkaKk3vfCd2jDOIww4pUk0xtg9JRde5UogyQ
89-

integrations/pgsql.ini.tmpl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ SCHEMA = {{TEST_PGSQL_SCHEMA}}
1111
SSL_MODE = disable
1212

1313
[indexer]
14-
ISSUE_INDEXER_PATH = integrations/indexers-pgsql/issues.bleve
14+
ISSUE_INDEXER_PATH = integrations/gitea-integration-pgsql/indexers/issues.bleve
15+
ISSUE_INDEXER_QUEUE_DIR = integrations/gitea-integration-pgsql/indexers/issues.queue
1516
REPO_INDEXER_ENABLED = true
16-
REPO_INDEXER_PATH = integrations/indexers-pgsql/repos.bleve
17+
REPO_INDEXER_PATH = integrations/gitea-integration-pgsql/indexers/repos.bleve
1718

1819
[queue.code_indexer]
1920
TYPE = immediate
@@ -25,8 +26,10 @@ TYPE = immediate
2526
ROOT = {{REPO_TEST_DIR}}integrations/gitea-integration-pgsql/gitea-repositories
2627

2728
[repository.local]
28-
LOCAL_COPY_PATH = tmp/local-repo-pgsql
29-
LOCAL_WIKI_PATH = tmp/local-wiki-pgsql
29+
LOCAL_COPY_PATH = integrations/gitea-integration-pgsql/tmp/local-repo
30+
31+
[repository.upload]
32+
TEMP_PATH = integrations/gitea-integration-pgsql/tmp/uploads
3033

3134
[repository.signing]
3235
SIGNING_KEY = none
@@ -40,14 +43,14 @@ SSH_LISTEN_HOST = localhost
4043
SSH_PORT = 2202
4144
START_SSH_SERVER = true
4245
LFS_START_SERVER = true
43-
LFS_CONTENT_PATH = integrations/gitea-integration-pgsql/data/lfs-pgsql
46+
LFS_CONTENT_PATH = integrations/gitea-integration-pgsql/data/lfs
4447
OFFLINE_MODE = false
4548
LFS_JWT_SECRET = Tv_MjmZuHqpIY6GFl12ebgkRAMt4RlWt0v4EHKSXO0w
4649
APP_DATA_PATH = integrations/gitea-integration-pgsql/data
4750
BUILTIN_SSH_SERVER_USER = git
4851

4952
[attachment]
50-
PATH = integrations/gitea-integration-pgsql/data
53+
PATH = integrations/gitea-integration-pgsql/data/attachments
5154

5255
[mailer]
5356
ENABLED = true

integrations/sqlite.ini.tmpl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ DB_TYPE = sqlite3
66
PATH = integrations/gitea-integration-sqlite/gitea.db
77

88
[indexer]
9-
ISSUE_INDEXER_PATH = integrations/indexers-sqlite/issues.bleve
9+
ISSUE_INDEXER_PATH = integrations/gitea-integration-sqlite/indexers/issues.bleve
10+
ISSUE_INDEXER_QUEUE_DIR = integrations/gitea-integration-sqlite/indexers/issues.queue
1011
REPO_INDEXER_ENABLED = true
11-
REPO_INDEXER_PATH = integrations/indexers-sqlite/repos.bleve
12+
REPO_INDEXER_PATH = integrations/gitea-integration-sqlite/indexers/repos.bleve
1213

1314
[queue.code_indexer]
1415
TYPE = immediate
@@ -20,8 +21,10 @@ TYPE = immediate
2021
ROOT = {{REPO_TEST_DIR}}integrations/gitea-integration-sqlite/gitea-repositories
2122

2223
[repository.local]
23-
LOCAL_COPY_PATH = tmp/local-repo-sqlite
24-
LOCAL_WIKI_PATH = tmp/local-wiki-sqlite
24+
LOCAL_COPY_PATH = integrations/gitea-integration-sqlite/tmp/local-repo
25+
26+
[repository.upload]
27+
TEMP_PATH = integrations/gitea-integration-sqlite/tmp/uploads
2528

2629
[repository.signing]
2730
SIGNING_KEY = none
@@ -35,15 +38,15 @@ SSH_LISTEN_HOST = localhost
3538
SSH_PORT = 2203
3639
START_SSH_SERVER = true
3740
LFS_START_SERVER = true
38-
LFS_CONTENT_PATH = integrations/gitea-integration-sqlite/data
41+
LFS_CONTENT_PATH = integrations/gitea-integration-sqlite/data/lfs
3942
OFFLINE_MODE = false
4043
LFS_JWT_SECRET = Tv_MjmZuHqpIY6GFl12ebgkRAMt4RlWt0v4EHKSXO0w
4144
APP_DATA_PATH = integrations/gitea-integration-sqlite/data
4245
ENABLE_GZIP = true
4346
BUILTIN_SSH_SERVER_USER = git
4447

4548
[attachment]
46-
PATH = integrations/gitea-integration-sqlite/data
49+
PATH = integrations/gitea-integration-sqlite/data/attachments
4750

4851
[mailer]
4952
ENABLED = true
@@ -67,7 +70,6 @@ ENABLE_FEDERATED_AVATAR = false
6770
AVATAR_UPLOAD_PATH = integrations/gitea-integration-sqlite/data/avatars
6871
REPOSITORY_AVATAR_UPLOAD_PATH = integrations/gitea-integration-sqlite/data/repo-avatars
6972

70-
7173
[session]
7274
PROVIDER = file
7375
PROVIDER_CONFIG = integrations/gitea-integration-sqlite/data/sessions

models/action.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,3 +395,13 @@ func activityQueryCondition(opts GetFeedsOptions) (builder.Cond, error) {
395395

396396
return cond, nil
397397
}
398+
399+
// DeleteOldActions deletes all old actions from database.
400+
func DeleteOldActions(olderThan time.Duration) (err error) {
401+
if olderThan <= 0 {
402+
return nil
403+
}
404+
405+
_, err = x.Where("created_unix < ?", time.Now().Add(-olderThan).Unix()).Delete(&Action{})
406+
return
407+
}

models/consistency.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,15 @@ func CountOrphanedObjects(subject, refobject, joinCond string) (int64, error) {
296296

297297
// DeleteOrphanedObjects delete subjects with have no existing refobject anymore
298298
func DeleteOrphanedObjects(subject, refobject, joinCond string) error {
299-
_, err := x.In("id", builder.Select("`"+subject+"`.id").
299+
subQuery := builder.Select("`"+subject+"`.id").
300300
From("`"+subject+"`").
301301
Join("LEFT", "`"+refobject+"`", joinCond).
302-
Where(builder.IsNull{"`" + refobject + "`.id"})).
303-
Delete("`" + subject + "`")
302+
Where(builder.IsNull{"`" + refobject + "`.id"})
303+
sql, args, err := builder.Delete(builder.In("id", subQuery)).From("`" + subject + "`").ToSQL()
304+
if err != nil {
305+
return err
306+
}
307+
_, err = x.Exec(append([]interface{}{sql}, args...)...)
304308
return err
305309
}
306310

models/consistency_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2021 Gitea. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package models
6+
7+
import (
8+
"testing"
9+
10+
"github.com/stretchr/testify/assert"
11+
)
12+
13+
func TestDeleteOrphanedObjects(t *testing.T) {
14+
assert.NoError(t, PrepareTestDatabase())
15+
16+
countBefore, err := x.Count(&PullRequest{})
17+
assert.NoError(t, err)
18+
19+
_, err = x.Insert(&PullRequest{IssueID: 1000}, &PullRequest{IssueID: 1001}, &PullRequest{IssueID: 1003})
20+
assert.NoError(t, err)
21+
22+
orphaned, err := CountOrphanedObjects("pull_request", "issue", "pull_request.issue_id=issue.id")
23+
assert.NoError(t, err)
24+
assert.EqualValues(t, 3, orphaned)
25+
26+
err = DeleteOrphanedObjects("pull_request", "issue", "pull_request.issue_id=issue.id")
27+
assert.NoError(t, err)
28+
29+
countAfter, err := x.Count(&PullRequest{})
30+
assert.NoError(t, err)
31+
assert.EqualValues(t, countBefore, countAfter)
32+
}

0 commit comments

Comments
 (0)