Skip to content

Commit c875ca8

Browse files
authored
Merge branch 'main' into support-search-user-by-email-in-api
2 parents 24b2f4c + 0bd7539 commit c875ca8

File tree

8 files changed

+1421
-8
lines changed

8 files changed

+1421
-8
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ TEST_PGSQL_DBNAME ?= testgitea
179179
TEST_PGSQL_USERNAME ?= postgres
180180
TEST_PGSQL_PASSWORD ?= postgres
181181
TEST_PGSQL_SCHEMA ?= gtestschema
182+
TEST_MINIO_ENDPOINT ?= minio:9000
182183
TEST_MSSQL_HOST ?= mssql:1433
183184
TEST_MSSQL_DBNAME ?= gitea
184185
TEST_MSSQL_USERNAME ?= sa
@@ -574,6 +575,7 @@ generate-ini-pgsql:
574575
-e 's|{{TEST_PGSQL_USERNAME}}|${TEST_PGSQL_USERNAME}|g' \
575576
-e 's|{{TEST_PGSQL_PASSWORD}}|${TEST_PGSQL_PASSWORD}|g' \
576577
-e 's|{{TEST_PGSQL_SCHEMA}}|${TEST_PGSQL_SCHEMA}|g' \
578+
-e 's|{{TEST_MINIO_ENDPOINT}}|${TEST_MINIO_ENDPOINT}|g' \
577579
-e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
578580
-e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \
579581
-e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \

modules/indexer/code/elasticsearch/elasticsearch.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
indexer_internal "code.gitea.io/gitea/modules/indexer/internal"
2121
inner_elasticsearch "code.gitea.io/gitea/modules/indexer/internal/elasticsearch"
2222
"code.gitea.io/gitea/modules/json"
23+
"code.gitea.io/gitea/modules/log"
2324
"code.gitea.io/gitea/modules/setting"
2425
"code.gitea.io/gitea/modules/timeutil"
2526
"code.gitea.io/gitea/modules/typesniffer"
@@ -197,8 +198,33 @@ func (b *Indexer) Index(ctx context.Context, repo *repo_model.Repository, sha st
197198
return nil
198199
}
199200

200-
// Delete deletes indexes by ids
201+
// Delete entries by repoId
201202
func (b *Indexer) Delete(ctx context.Context, repoID int64) error {
203+
if err := b.doDelete(ctx, repoID); err != nil {
204+
// Maybe there is a conflict during the delete operation, so we should retry after a refresh
205+
log.Warn("Deletion of entries of repo %v within index %v was erroneus. Trying to refresh index before trying again", repoID, b.inner.VersionedIndexName(), err)
206+
if err := b.refreshIndex(ctx); err != nil {
207+
return err
208+
}
209+
if err := b.doDelete(ctx, repoID); err != nil {
210+
log.Error("Could not delete entries of repo %v within index %v", repoID, b.inner.VersionedIndexName())
211+
return err
212+
}
213+
}
214+
return nil
215+
}
216+
217+
func (b *Indexer) refreshIndex(ctx context.Context) error {
218+
if _, err := b.inner.Client.Refresh(b.inner.VersionedIndexName()).Do(ctx); err != nil {
219+
log.Error("Error while trying to refresh index %v", b.inner.VersionedIndexName(), err)
220+
return err
221+
}
222+
223+
return nil
224+
}
225+
226+
// Delete entries by repoId
227+
func (b *Indexer) doDelete(ctx context.Context, repoID int64) error {
202228
_, err := b.inner.Client.DeleteByQuery(b.inner.VersionedIndexName()).
203229
Query(elastic.NewTermsQuery("repo_id", repoID)).
204230
Do(ctx)

options/locale/locale_ga-IE.ini

Lines changed: 1374 additions & 0 deletions
Large diffs are not rendered by default.

options/locale/locale_ja-JP.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,6 +1926,7 @@ pulls.delete.text=本当にこのプルリクエストを削除しますか? (
19261926
pulls.recently_pushed_new_branches=%[2]s 、あなたはブランチ <strong>%[1]s</strong> にプッシュしました
19271927

19281928
pull.deleted_branch=(削除済み):%s
1929+
pull.agit_documentation=AGitに関するドキュメントを確認する
19291930

19301931
comments.edit.already_changed=コメントの変更を保存できません。 他のユーザーによって内容がすでに変更されているようです。 変更を上書きしないようにするため、ページを更新してからもう一度編集してください
19311932

options/locale/locale_pt-PT.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,7 @@ issue_labels_helper=Escolha um conjunto de rótulos para as questões.
10401040
license=Licença
10411041
license_helper=Escolha um ficheiro de licença.
10421042
license_helper_desc=Uma licença rege o que os outros podem, ou não, fazer com o seu código fonte. Não tem a certeza sobre qual a mais indicada para o seu trabalho? Veja: <a target="_blank" rel="noopener noreferrer" href="%s">Escolher uma licença.</a>
1043+
multiple_licenses=Múltiplas licenças
10431044
object_format=Formato dos elementos
10441045
object_format_helper=Formato dos elementos do repositório. Não poderá ser alterado mais tarde. SHA1 é o mais compatível.
10451046
readme=README
@@ -2941,6 +2942,7 @@ dashboard.start_schedule_tasks=Iniciar tarefas de agendamento das operações
29412942
dashboard.sync_branch.started=Sincronização de ramos iniciada
29422943
dashboard.sync_tag.started=Sincronização de etiquetas iniciada
29432944
dashboard.rebuild_issue_indexer=Reconstruir indexador de questões
2945+
dashboard.sync_repo_licenses=Sincronizar licenças do repositório
29442946

29452947
users.user_manage_panel=Gestão das contas de utilizadores
29462948
users.new_account=Criar conta de utilizador

tests/integration/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,15 @@ TEST_MYSQL_HOST=localhost:3306 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=root T
5656
## Run pgsql integration tests
5757
Setup a pgsql database inside docker
5858
```
59-
docker run -e "POSTGRES_DB=test" -p 5432:5432 --rm --name pgsql postgres:latest #(just ctrl-c to stop db and clean the container)
59+
docker run -e "POSTGRES_DB=test" -e "POSTGRES_USER=postgres" -e "POSTGRES_PASSWORD=postgres" -p 5432:5432 --rm --name pgsql postgres:latest #(just ctrl-c to stop db and clean the container)
60+
```
61+
Setup minio inside docker
62+
```
63+
docker run --rm -p 9000:9000 -e MINIO_ROOT_USER=123456 -e MINIO_ROOT_PASSWORD=12345678 --name minio bitnami/minio:2023.8.31
6064
```
6165
Start tests based on the database container
6266
```
63-
TEST_PGSQL_HOST=localhost:5432 TEST_PGSQL_DBNAME=test TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-pgsql
67+
TEST_MINIO_ENDPOINT=localhost:9000 TEST_PGSQL_HOST=localhost:5432 TEST_PGSQL_DBNAME=postgres TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-pgsql
6468
```
6569

6670
## Run mssql integration tests

tests/integration/README_ZH.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ make test-sqlite
4242
## 如何使用 mysql 数据库进行集成测试
4343
首先在docker容器里部署一个 mysql 数据库
4444
```
45-
docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -p 3306:3306 --rm --name mysql mysql:8 #(just ctrl-c to stop db and clean the container)
45+
docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -p 3306:3306 --rm --name mysql mysql:8 #(just ctrl-c to stop db and clean the container)
4646
```
4747
之后便可以基于这个数据库进行集成测试
4848
```
@@ -52,17 +52,21 @@ TEST_MYSQL_HOST=localhost:3306 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=root T
5252
## 如何使用 pgsql 数据库进行集成测试
5353
同上,首先在 docker 容器里部署一个 pgsql 数据库
5454
```
55-
docker run -e "POSTGRES_DB=test" -p 5432:5432 --rm --name pgsql postgres:14 #(just ctrl-c to stop db and clean the container)
55+
docker run -e "POSTGRES_DB=test" -e "POSTGRES_USER=postgres" -e "POSTGRES_PASSWORD=postgres" -p 5432:5432 --rm --name pgsql postgres:latest #(just ctrl-c to stop db and clean the container)
56+
```
57+
在docker内设置minio
58+
```
59+
docker run --rm -p 9000:9000 -e MINIO_ROOT_USER=123456 -e MINIO_ROOT_PASSWORD=12345678 --name minio bitnami/minio:2023.8.31
5660
```
5761
之后便可以基于这个数据库进行集成测试
5862
```
59-
TEST_PGSQL_HOST=localhost:5432 TEST_PGSQL_DBNAME=test TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-pgsql
63+
TEST_MINIO_ENDPOINT=localhost:9000 TEST_PGSQL_HOST=localhost:5432 TEST_PGSQL_DBNAME=postgres TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-pgsql
6064
```
6165

6266
## Run mssql integration tests
6367
同上,首先在 docker 容器里部署一个 mssql 数据库
6468
```
65-
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_PID=Standard" -e "SA_PASSWORD=MwantsaSecurePassword1" -p 1433:1433 --rm --name mssql microsoft/mssql-server-linux:latest #(just ctrl-c to stop db and clean the container)
69+
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_PID=Standard" -e "SA_PASSWORD=MwantsaSecurePassword1" -p 1433:1433 --rm --name mssql microsoft/mssql-server-linux:latest #(just ctrl-c to stop db and clean the container)
6670
```
6771
之后便可以基于这个数据库进行集成测试
6872
```

tests/pgsql.ini.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ MINIO_BASE_PATH = repo-avatars/
115115
[storage]
116116
STORAGE_TYPE = minio
117117
SERVE_DIRECT = false
118-
MINIO_ENDPOINT = minio:9000
118+
MINIO_ENDPOINT = {{TEST_MINIO_ENDPOINT}}
119119
MINIO_ACCESS_KEY_ID = 123456
120120
MINIO_SECRET_ACCESS_KEY = 12345678
121121
MINIO_BUCKET = gitea

0 commit comments

Comments
 (0)