Skip to content

Commit 704e177

Browse files
committed
Merge branch 'main' into codebase-fake-input
2 parents 6d2c290 + b59875a commit 704e177

31 files changed

+270
-152
lines changed

docs/content/doc/advanced/config-cheat-sheet.zh-cn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ menu:
8484

8585
## Database (`database`)
8686

87-
- `DB_TYPE`: 数据库类型,可选 `mysql`, `postgres`, `mssql`, `tidb``sqlite3`
87+
- `DB_TYPE`: 数据库类型,可选 `mysql`, `postgres`, `mssql``sqlite3`
8888
- `HOST`: 数据库服务器地址和端口。
8989
- `NAME`: 数据库名称。
9090
- `USER`: 数据库用户名。
9191
- `PASSWD`: 数据库用户密码。
9292
- `SSL_MODE`: MySQL 或 PostgreSQL数据库是否启用SSL模式。
9393
- `CHARSET`: **utf8mb4**: 仅当数据库为 MySQL 时有效, 可以为 "utf8" 或 "utf8mb4"。注意:如果使用 "utf8mb4",你的 MySQL InnoDB 版本必须在 5.6 以上。
94-
- `PATH`: Tidb 或者 SQLite3 数据文件存放路径。
94+
- `PATH`: SQLite3 数据文件存放路径。
9595
- `LOG_SQL`: **true**: 显示生成的SQL,默认为真。
9696
- `MAX_IDLE_CONNS` **0**: 最大空闲数据库连接
9797
- `CONN_MAX_LIFETIME` **3s**: 数据库连接最大存活时间

docs/content/page/index.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Windows, on architectures like amd64, i386, ARM, PowerPC, and others.
7373
- PostgreSQL (>=10)
7474
- SQLite3
7575
- MSSQL (>=2008R2 SP3)
76-
- TiDB (experimental, not recommended)
76+
- TiDB (MySQL protocol)
7777
- Configuration file
7878
- [app.ini](https://github.com/go-gitea/gitea/blob/master/custom/conf/app.example.ini)
7979
- Admin panel

docs/content/page/index.fr-fr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Le but de ce projet est de fournir de la manière la plus simple, la plus rapide
6868
- PostgreSQL
6969
- SQLite3
7070
- MSSQL
71-
- [TiDB](https://github.com/pingcap/tidb) (expérimental)
71+
- [TiDB](https://github.com/pingcap/tidb) (MySQL protocol)
7272
- Fichier de configuration
7373
- Voir [ici](https://github.com/go-gitea/gitea/blob/master/custom/conf/app.example.ini)
7474
- Panel d'administration

docs/content/page/index.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Gitea的首要目标是创建一个极易安装,运行非常快速,安装和
3232
- 支持自定义源的 Gravatar 和 Federated Avatar
3333
- 支持邮件服务
3434
- 支持后台管理面板
35-
- 支持 MySQL、PostgreSQL、SQLite3, MSSQL 和 TiDB(实验性支持) 数据库
35+
- 支持 MySQL、PostgreSQL、SQLite3MSSQL 和 TiDB(MySQL) 数据库
3636
- 支持多语言本地化(21 种语言)
3737

3838
## 系统要求

docs/content/page/index.zh-tw.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Gitea 是從 [Gogs](http://gogs.io) Fork 出來的,請閱讀部落格文章 [G
6969
- PostgreSQL
7070
- SQLite3
7171
- MSSQL
72-
- TiDB(實驗中, 不建議使用
72+
- TiDB(MySQL 協議
7373
- 設定檔
7474
- [app.ini](https://github.com/go-gitea/gitea/blob/master/custom/conf/app.example.ini)
7575
- 管理員面板

models/engine_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ func TestDumpDatabase(t *testing.T) {
2828
}
2929
assert.NoError(t, db.GetEngine(db.DefaultContext).Sync2(new(Version)))
3030

31-
for _, dbName := range setting.SupportedDatabases {
32-
dbType := setting.GetDBTypeByName(dbName)
31+
for _, dbType := range setting.SupportedDatabaseTypes {
3332
assert.NoError(t, db.DumpDatabase(filepath.Join(dir, dbType+".sql"), dbType))
3433
}
3534
}

models/issue.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,8 @@ func sortIssuesSession(sess *xorm.Session, sortType string, priorityRepoID int64
12191219
"ELSE issue.deadline_unix END DESC")
12201220
case "priorityrepo":
12211221
sess.OrderBy("CASE WHEN issue.repo_id = " + strconv.FormatInt(priorityRepoID, 10) + " THEN 1 ELSE 2 END, issue.created_unix DESC")
1222+
case "project-column-sorting":
1223+
sess.Asc("project_issue.sorting")
12221224
default:
12231225
sess.Desc("issue.created_unix")
12241226
}

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ var migrations = []Migration{
359359
NewMigration("Drop table remote_version (if exists)", dropTableRemoteVersion),
360360
// v202 -> v203
361361
NewMigration("Create key/value table for user settings", createUserSettingsTable),
362+
// v203 -> v204
363+
NewMigration("Add Sorting to ProjectIssue table", addProjectIssueSorting),
362364
}
363365

364366
// GetCurrentDBVersion returns the current db version

models/migrations/v203.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2021 The Gitea Authors. 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 migrations
6+
7+
import (
8+
"xorm.io/xorm"
9+
)
10+
11+
func addProjectIssueSorting(x *xorm.Engine) error {
12+
// ProjectIssue saves relation from issue to a project
13+
type ProjectIssue struct {
14+
Sorting int64 `xorm:"NOT NULL DEFAULT 0"`
15+
}
16+
17+
return x.Sync2(new(ProjectIssue))
18+
}

models/project_board.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ func (b *ProjectBoard) LoadIssues() (IssueList, error) {
265265
issues, err := Issues(&IssuesOptions{
266266
ProjectBoardID: b.ID,
267267
ProjectID: b.ProjectID,
268+
SortType: "project-column-sorting",
268269
})
269270
if err != nil {
270271
return nil, err
@@ -276,6 +277,7 @@ func (b *ProjectBoard) LoadIssues() (IssueList, error) {
276277
issues, err := Issues(&IssuesOptions{
277278
ProjectBoardID: -1, // Issues without ProjectBoardID
278279
ProjectID: b.ProjectID,
280+
SortType: "project-column-sorting",
279281
})
280282
if err != nil {
281283
return nil, err

models/project_issue.go

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type ProjectIssue struct {
2020

2121
// If 0, then it has not been added to a specific board in the project
2222
ProjectBoardID int64 `xorm:"INDEX"`
23+
Sorting int64 `xorm:"NOT NULL DEFAULT 0"`
2324
}
2425

2526
func init() {
@@ -184,34 +185,34 @@ func addUpdateIssueProject(ctx context.Context, issue *Issue, doer *user_model.U
184185
// |_| |_| \___// |\___|\___|\__|____/ \___/ \__,_|_| \__,_|
185186
// |__/
186187

187-
// MoveIssueAcrossProjectBoards move a card from one board to another
188-
func MoveIssueAcrossProjectBoards(issue *Issue, board *ProjectBoard) error {
189-
ctx, committer, err := db.TxContext()
190-
if err != nil {
191-
return err
192-
}
193-
defer committer.Close()
194-
sess := db.GetEngine(ctx)
195-
196-
var pis ProjectIssue
197-
has, err := sess.Where("issue_id=?", issue.ID).Get(&pis)
198-
if err != nil {
199-
return err
200-
}
201-
202-
if !has {
203-
return fmt.Errorf("issue has to be added to a project first")
204-
}
188+
// MoveIssuesOnProjectBoard moves or keeps issues in a column and sorts them inside that column
189+
func MoveIssuesOnProjectBoard(board *ProjectBoard, sortedIssueIDs map[int64]int64) error {
190+
return db.WithTx(func(ctx context.Context) error {
191+
sess := db.GetEngine(ctx)
205192

206-
pis.ProjectBoardID = board.ID
207-
if _, err := sess.ID(pis.ID).Cols("project_board_id").Update(&pis); err != nil {
208-
return err
209-
}
193+
issueIDs := make([]int64, 0, len(sortedIssueIDs))
194+
for _, issueID := range sortedIssueIDs {
195+
issueIDs = append(issueIDs, issueID)
196+
}
197+
count, err := sess.Table(new(ProjectIssue)).Where("project_id=?", board.ProjectID).In("issue_id", issueIDs).Count()
198+
if err != nil {
199+
return err
200+
}
201+
if int(count) != len(sortedIssueIDs) {
202+
return fmt.Errorf("all issues have to be added to a project first")
203+
}
210204

211-
return committer.Commit()
205+
for sorting, issueID := range sortedIssueIDs {
206+
_, err = sess.Exec("UPDATE `project_issue` SET project_board_id=?, sorting=? WHERE issue_id=?", board.ID, sorting, issueID)
207+
if err != nil {
208+
return err
209+
}
210+
}
211+
return nil
212+
})
212213
}
213214

214215
func (pb *ProjectBoard) removeIssues(e db.Engine) error {
215-
_, err := e.Exec("UPDATE `project_issue` SET project_board_id = 0 WHERE project_board_id = ? ", pb.ID)
216+
_, err := e.Exec("UPDATE `project_issue` SET project_board_id = 0, sorting = 0 WHERE project_board_id = ? ", pb.ID)
216217
return err
217218
}

modules/setting/database.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ import (
1616
)
1717

1818
var (
19-
// SupportedDatabases includes all supported databases type
20-
SupportedDatabases = []string{"MySQL", "PostgreSQL", "MSSQL"}
21-
dbTypes = map[string]string{"MySQL": "mysql", "PostgreSQL": "postgres", "MSSQL": "mssql", "SQLite3": "sqlite3"}
19+
// SupportedDatabaseTypes includes all XORM supported databases type, sqlite3 maybe added by `database_sqlite3.go`
20+
SupportedDatabaseTypes = []string{"mysql", "postgres", "mssql"}
21+
// DatabaseTypeNames contains the friendly names for all database types
22+
DatabaseTypeNames = map[string]string{"mysql": "MySQL", "postgres": "PostgreSQL", "mssql": "MSSQL", "sqlite3": "SQLite3"}
2223

2324
// EnableSQLite3 use SQLite3, set by build flag
2425
EnableSQLite3 bool
@@ -52,11 +53,6 @@ var (
5253
}
5354
)
5455

55-
// GetDBTypeByName returns the database type as it defined on XORM according the given name
56-
func GetDBTypeByName(name string) string {
57-
return dbTypes[name]
58-
}
59-
6056
// InitDBConfig loads the database settings
6157
func InitDBConfig() {
6258
sec := Cfg.Section("database")

modules/setting/database_sqlite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ import (
1313

1414
func init() {
1515
EnableSQLite3 = true
16-
SupportedDatabases = append(SupportedDatabases, "SQLite3")
16+
SupportedDatabaseTypes = append(SupportedDatabaseTypes, "sqlite3")
1717
}

modules/setting/setting.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -548,25 +548,25 @@ func SetCustomPathAndConf(providedCustom, providedConf, providedWorkPath string)
548548

549549
// LoadFromExisting initializes setting options from an existing config file (app.ini)
550550
func LoadFromExisting() {
551-
loadFromConf(false)
551+
loadFromConf(false, "")
552552
}
553553

554554
// LoadAllowEmpty initializes setting options, it's also fine that if the config file (app.ini) doesn't exist
555555
func LoadAllowEmpty() {
556-
loadFromConf(true)
556+
loadFromConf(true, "")
557557
}
558558

559559
// LoadForTest initializes setting options for tests
560-
func LoadForTest() {
561-
loadFromConf(true)
560+
func LoadForTest(extraConfigs ...string) {
561+
loadFromConf(true, strings.Join(extraConfigs, "\n"))
562562
if err := PrepareAppDataPath(); err != nil {
563563
log.Fatal("Can not prepare APP_DATA_PATH: %v", err)
564564
}
565565
}
566566

567567
// loadFromConf initializes configuration context.
568568
// NOTE: do not print any log except error.
569-
func loadFromConf(allowEmpty bool) {
569+
func loadFromConf(allowEmpty bool, extraConfig string) {
570570
Cfg = ini.Empty()
571571

572572
if WritePIDFile && len(PIDFile) > 0 {
@@ -585,6 +585,12 @@ func loadFromConf(allowEmpty bool) {
585585
log.Fatal("Unable to find configuration file: %q.\nEnsure you are running in the correct environment or set the correct configuration file with -c.", CustomConf)
586586
} // else: no config file, a config file might be created at CustomConf later (might not)
587587

588+
if extraConfig != "" {
589+
if err = Cfg.Append([]byte(extraConfig)); err != nil {
590+
log.Fatal("Unable to append more config: %v", err)
591+
}
592+
}
593+
588594
Cfg.NameMapper = ini.SnackCase
589595

590596
homeDir, err := com.HomeDir()

options/locale/locale_en-US.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ license_desc = Go get <a target="_blank" rel="noopener noreferrer" href="https:/
124124
install = Installation
125125
title = Initial Configuration
126126
docker_helper = If you run Gitea inside Docker, please read the <a target="_blank" rel="noopener noreferrer" href="%s">documentation</a> before changing any settings.
127-
requite_db_desc = Gitea requires MySQL, PostgreSQL, MSSQL or SQLite3.
127+
require_db_desc = Gitea requires MySQL, PostgreSQL, MSSQL, SQLite3 or TiDB (MySQL protocol).
128128
db_title = Database Settings
129129
db_type = Database Type
130130
host = Host

options/locale/locale_es-ES.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ reinstall_error=Usted está intentando instalar en una base de datos de Gitea ex
142142
reinstall_confirm_message=Reinstalar con una base de datos de Gitea existente puede causar múltiples problemas. En la mayoría de los casos, debería utilizar su actual "app.ini" para ejecutar Gitea. Si sabe lo que está haciendo, confirme lo siguiente:
143143
reinstall_confirm_check_1=Los datos cifrados por el SECRET_KEY en el app.ini puede perderse: es posible que los usuarios no puedan iniciar sesión con 2FA/OTP & réplicas no funcionen correctamente. Marcando esta casilla confirma que el archivo app.ini actual contiene el SECRET_KEY.
144144
reinstall_confirm_check_2=Es posible que los repositorios y configuraciones tengan que volver a sincronizarse. Al marcar esta casilla confirma que resincronizará manualmente los ganchos de los repositorios y el archivo authorized_keys. Confirma que se asegurará de que la configuración del repositorio y la réplica son correctas.
145-
reinstall_confirm_check_3=Confirma que está absolutamente seguro de que este Gitea se está ejecutando con el app.ini correcto y que está seguro de que tiene que volver a instalar. Confirma que reconoce los riesgos anteriores.
146145
err_empty_db_path=La ruta a la base de datos SQLite3 no puede estar vacía.
147146
no_admin_and_disable_registration=No puede deshabilitar el auto-registro sin crear una cuenta de administrador.
148147
err_empty_admin_password=La contraseña del administrador no puede estar vacía.

options/locale/locale_ja-JP.ini

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ ssl_mode=SSL
138138
charset=文字セット
139139
path=パス
140140
sqlite_helper=SQLite3のデータベースファイルパス。<br>Giteaをサービスとして実行する場合は絶対パスを入力します。
141+
reinstall_error=既存のGiteaデータベースへインストールしようとしています
142+
reinstall_confirm_message=既存のGiteaデータベースに再インストールすると、複数の問題が発生する可能性があります。 たいていの場合は、既存の"app.ini"を使用してGiteaを実行すべきです。 何をしているか分かっている場合は、以下を確認してください。
143+
reinstall_confirm_check_1=App.ini 内の SECRET_KEY により暗号化されたデータは失われる可能性があります: ユーザーが 2FA/OTP でログインできなかったり、ミラーが正しく機能しない可能性があります。 このボックスにチェックをいれた場合は、現在のapp.iniファイルには正しいSECRET_KEYが含まれているものとします。
144+
reinstall_confirm_check_2=リポジトリと設定の再同期が必要になる場合があります。 このボックスにチェックをいれた場合、リポジトリのフックと authorized_keys ファイルはあなたが手動で再設定するものとします。 またリポジトリとミラーの設定も、あなたが正しく設定するものとします。
145+
reinstall_confirm_check_3=このGiteaが正しい場所にある app.ini で動作しており、確実に再インストールの必要性があるものとします。 あなたは上記のリスクを承知しています。
141146
err_empty_db_path=SQLite3のデータベースパスを空にすることはできません。
142147
no_admin_and_disable_registration=管理者アカウントを作成せずに、セルフ登録を無効にすることはできません。
143148
err_empty_admin_password=管理者パスワードは空にできません。
@@ -203,8 +208,12 @@ install_btn_confirm=Giteaをインストール
203208
test_git_failed='git'コマンドが確認できません: %v
204209
sqlite3_not_available=GiteaのこのバージョンはSQLite3をサポートしていません。 公式のバイナリ版を %s からダウンロードしてください。 ('gobuild'版でないもの)
205210
invalid_db_setting=データベース設定が無効です: %v
211+
invalid_db_table=データベーステーブルの '%s' が無効です: %v
206212
invalid_repo_path=リポジトリのルートパスが無効です: %v
213+
invalid_app_data_path=アプリのデータパス (APP_DATA_PATH) が無効です: %v
207214
run_user_not_match=実行ユーザー名が、現在のユーザー名ではありません: %s -> %s
215+
internal_token_failed=内部トークンの生成に失敗しました: %v
216+
secret_key_failed=シークレットキーの生成に失敗しました: %v
208217
save_config_failed=設定ファイルの保存に失敗しました: %v
209218
invalid_admin_setting=管理者アカウントの設定が無効です: %v
210219
install_success=ようこそ! Giteaを選択していただき、ありがとうございます。楽しんでください!
@@ -917,6 +926,7 @@ migrate.gitlab.description=gitlab.com やその他の GitLab インスタンス
917926
migrate.gitea.description=gitea.com やその他の Gitea インスタンスからデータを移行します。
918927
migrate.gogs.description=notabug.org やその他の Gogs インスタンスからデータを移行します。
919928
migrate.onedev.description=code.onedev.io やその他の OneDev インスタンスからデータを移行します。
929+
migrate.codebase.description=codebasehq.com からデータを移行します。
920930
migrate.gitbucket.description=GitBucket インスタンスからデータを移行します。
921931
migrate.migrating_git=Gitデータ移行中
922932
migrate.migrating_topics=トピック移行中
@@ -1575,6 +1585,7 @@ wiki.page_already_exists=既に同じ名前のUncyclo ページが存在します
15751585
wiki.reserved_page=Uncycloページ名 '%s' は予約されています。
15761586
wiki.pages=ページ
15771587
wiki.last_updated=最終更新 %s
1588+
wiki.page_name_desc=この Uncyclo ページの名前を入力してください。いくつかの特別な名前として 'Home', '_Sidebar''_Footer' があります。
15781589

15791590
activity=アクティビティ
15801591
activity.period.filter_label=期間:
@@ -2696,6 +2707,7 @@ monitor.execute_time=実行時間
26962707
monitor.process.cancel=処理をキャンセル
26972708
monitor.process.cancel_desc=処理をキャンセルするとデータが失われる可能性があります
26982709
monitor.process.cancel_notices=キャンセル: <strong>%s</strong>?
2710+
monitor.process.children=子プロセス
26992711
monitor.queues=キュー
27002712
monitor.queue=キュー: %s
27012713
monitor.queue.name=キュー名

options/locale/locale_pt-PT.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1604,7 +1604,7 @@ activity.title.user_1=%d utilizador
16041604
activity.title.user_n=%d utilizadores
16051605
activity.title.prs_1=%d pedido de integração
16061606
activity.title.prs_n=%d Pedidos de integração
1607-
activity.title.prs_merged_by=%s integrado por %s
1607+
activity.title.prs_merged_by=%s executado(s) por %s
16081608
activity.title.prs_opened_by=%s proposto por %s
16091609
activity.merged_prs_label=Integrados
16101610
activity.opened_prs_label=Propostos

options/locale/locale_zh-CN.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ reinstall_error=您正在尝试安装到一个已经有 Gitea 数据的数据库
142142
reinstall_confirm_message=使用现有的 Gitea 数据库重新安装可能会导致多个问题。在大多数情况下,你应该使用你现有的 “app.ini” 来运行 Gitea。如果你知道自己在做什么,请确认以下内容:
143143
reinstall_confirm_check_1=使用 app.ini 中 SECRET KEY 加密的数据可能会丢失:用户可能无法使用 2FA/OTP 登录,仓库镜像可能无法正常工作。勾选此框,表示您确认当前 app.ini 文件包含正确的 SECRET KEY。
144144
reinstall_confirm_check_2=代码仓库和设置可能需要重新同步。勾选此框,表示您确认将手动重新同步仓库和 SSH authorized_keys 的钩子。您确认您将确保代码仓库和镜像设置是正确的。
145-
reinstall_confirm_check_3=你确认你绝对肯定这个 Gitea 在正确的 app.ini 位置上运行,而且你确定你必须重新安装。你确定你知晓上述风险
145+
reinstall_confirm_check_3=你确认你绝对肯定这个 Gitea 在正确的 app.ini 位置上运行,而且你确定你必须重新安装。你确认你知晓上述风险
146146
err_empty_db_path=SQLite 数据库文件路径不能为空。
147147
no_admin_and_disable_registration=您不能够在未创建管理员用户的情况下禁止注册。
148148
err_empty_admin_password=管理员密码不能为空。

options/locale/locale_zh-TW.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,7 @@ wiki.page_already_exists=相同名稱的 Uncyclo 頁面已經存在。
15761576
wiki.reserved_page=Uncyclo 頁面名稱 "%s" 是被保留的。
15771577
wiki.pages=所有頁面
15781578
wiki.last_updated=最後更新於 %s
1579+
wiki.page_name_desc=輸入此 Uncyclo 頁面的名稱。一些特殊名稱有:「Home」、「_Sidebar」、「_Footer」等。
15791580

15801581
activity=動態
15811582
activity.period.filter_label=期間:

0 commit comments

Comments
 (0)