From fdc784dbf482a790baaa1dd1f9dde5a8b8e4dadb Mon Sep 17 00:00:00 2001 From: singuliere <35190819+singuliere@users.noreply.github.com> Date: Tue, 31 May 2022 00:47:55 +0200 Subject: [PATCH 1/7] docs: update the ROOT documentation and error messages (#19832) * docs: update the ROOT documentation and error messages * The documentation now reflects what happens in the setting/repository.go::newRepository function: filepath.Join(AppWorkPath, RepoRootPath) was missing. * The error message displayed when RepoRootPath is not found now displays the value of RepoRootPath. Given the complexity of the construction of this value, only referring to it in the abstract is likely to be misleading to the Gitea admin trying to interpret the message. Co-authored-by: delvh --- cmd/serv.go | 2 +- custom/conf/app.example.ini | 3 ++- docs/content/doc/advanced/config-cheat-sheet.en-us.md | 4 ++-- docs/content/doc/help/faq.en-us.md | 5 +++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/serv.go b/cmd/serv.go index 340f591dce0b..adfbc6024ca7 100644 --- a/cmd/serv.go +++ b/cmd/serv.go @@ -302,7 +302,7 @@ func runServ(c *cli.Context) error { if _, err := os.Stat(setting.RepoRootPath); err != nil { if os.IsNotExist(err) { return fail("Incorrect configuration.", - "Directory `[repository]` `ROOT` was not found, please check if $GITEA_WORK_DIR is passed to the SSH connection or make `[repository]` `ROOT` an absolute value.") + "Directory `[repository]` `ROOT` %s was not found, please check if $GITEA_WORK_DIR is passed to the SSH connection or make `[repository]` `ROOT` an absolute value.", setting.RepoRootPath) } } diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 8362f228123d..03bdf4535040 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -813,7 +813,8 @@ PATH = ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;[repository] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Root path for storing all repository data. It must be an absolute path. By default, it is stored in a sub-directory of `APP_DATA_PATH`. +;; Root path for storing all repository data. By default, it is set to %(APP_DATA_PATH)/gitea-repositories. +;; A relative path is interpreted as %(GITEA_WORK_DIR)/%(ROOT) ;ROOT = ;; ;; The script type this server supports. Usually this is `bash`, but some users report that only `sh` is available. diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 785fd3d6c25e..9d7f6c126cc6 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -42,8 +42,8 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`. ## Repository (`repository`) -- `ROOT`: **data/gitea-repositories/**: Root path for storing all repository data. It must be - an absolute path. By default it is stored in a sub-directory of `APP_DATA_PATH`. +- `ROOT`: **%(APP_DATA_PATH)/gitea-repositories**: Root path for storing all repository data. + A relative path is interpreted as **%(GITEA_WORK_DIR)/%(ROOT)**. - `SCRIPT_TYPE`: **bash**: The script type this server supports. Usually this is `bash`, but some users report that only `sh` is available. - `DETECTED_CHARSETS_ORDER`: **UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE, ISO-8859, windows-1252, ISO-8859, windows-1250, ISO-8859, ISO-8859, ISO-8859, windows-1253, ISO-8859, windows-1255, ISO-8859, windows-1251, windows-1256, KOI8-R, ISO-8859, windows-1254, Shift_JIS, GB18030, EUC-JP, EUC-KR, Big5, ISO-2022, ISO-2022, ISO-2022, IBM424_rtl, IBM424_ltr, IBM420_rtl, IBM420_ltr**: Tie-break order of detected charsets - if the detected charsets have equal confidence, charsets earlier in the list will be chosen in preference to those later. Adding `defaults` will place the unnamed charsets at that point. diff --git a/docs/content/doc/help/faq.en-us.md b/docs/content/doc/help/faq.en-us.md index ee5a37c948ec..a64cccfa66f4 100644 --- a/docs/content/doc/help/faq.en-us.md +++ b/docs/content/doc/help/faq.en-us.md @@ -64,8 +64,9 @@ https://github.com/loganinak/MigrateGitlabToGogs - Unix: Environment variable `HOME` - Windows: Environment variable `USERPROFILE`, else environment variables `HOMEDRIVE`+`HOMEPATH` - RepoRootPath - - `ROOT` in `app.ini` - - Else `%(AppDataPath)/gitea-repositories` + - `ROOT` in the \[repository] section of `app.ini` if absolute + - Else `%(AppWorkPath)/ROOT` if `ROOT` in the \[repository] section of `app.ini` if relative + - Default `%(AppDataPath)/gitea-repositories` - INI (config file) - `-c` flag - Else `%(CustomPath)/conf/app.ini` From e31c6166ee92c378c84570b2959f2fdb040d438a Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Tue, 31 May 2022 00:10:30 +0000 Subject: [PATCH 2/7] [skip ci] Updated translations via Crowdin --- options/locale/locale_el-GR.ini | 1 + options/locale/locale_ja-JP.ini | 2 ++ options/locale/locale_zh-CN.ini | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/options/locale/locale_el-GR.ini b/options/locale/locale_el-GR.ini index 04191d052f19..be471b964b72 100644 --- a/options/locale/locale_el-GR.ini +++ b/options/locale/locale_el-GR.ini @@ -778,6 +778,7 @@ webauthn_delete_key_desc=Αν αφαιρέσετε ένα κλειδί ασφα manage_account_links=Διαχείριση Συνδεδεμένων Λογαριασμών manage_account_links_desc=Αυτοί οι εξωτερικοί λογαριασμοί είναι συνδεδεμένοι στον Gitea λογαριασμό σας. account_links_not_available=Προς το παρόν δεν υπάρχουν εξωτερικοί λογαριασμοί συνδεδεμένοι με τον λογαριασμό σας στο Gitea. +link_account=Σύνδεση Λογαριασμού remove_account_link=Αφαίρεση Συνδεδεμένου Λογαριασμού remove_account_link_desc=Η κατάργηση ενός συνδεδεμένου λογαριασμού θα ανακαλέσει την πρόσβασή του στο λογαριασμό σας στο Gitea. Συνέχεια; remove_account_link_success=Ο συνδεδεμένος λογαριασμός έχει αφαιρεθεί. diff --git a/options/locale/locale_ja-JP.ini b/options/locale/locale_ja-JP.ini index e214f80d56f2..85e2fd31bee6 100644 --- a/options/locale/locale_ja-JP.ini +++ b/options/locale/locale_ja-JP.ini @@ -778,6 +778,7 @@ webauthn_delete_key_desc=セキュリティキーの登録を解除すると、 manage_account_links=連携アカウントの管理 manage_account_links_desc=これらの外部アカウントがGiteaアカウントと連携されています。 account_links_not_available=現在このGiteaアカウントが連携している外部アカウントはありません。 +link_account=アカウントをリンク remove_account_link=連携アカウントの削除 remove_account_link_desc=連携アカウントを削除し、Giteaアカウントへのアクセス権を取り消します。 続行しますか? remove_account_link_success=連携アカウントを削除しました。 @@ -2423,6 +2424,7 @@ dashboard.new_version_hint=Gitea %s が入手可能になりました。 現在 dashboard.statistic=サマリー dashboard.operations=メンテナンス操作 dashboard.system_status=システム状況 +dashboard.statistic_info=Giteaデータベースは %d ユーザー, %d 組織, %d 公開鍵, %d リポジトリ, %d ウォッチ, %d スター, ~%d アクション, %d アクセス, %d イシュー, %d コメント, %d ソーシャルアカウント, %d フォロー, %d ミラー, %d リリース, %d 認証ソース, %d Webhook, %d マイルストーン, %d ラベル, %d フックタスク, %d チーム, %d 更新タスク, %d 添付ファイル の情報を持っています。 dashboard.operation_name=操作の名称 dashboard.operation_switch=切り替え dashboard.operation_run=実行 diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 878067527074..3b5d8f826794 100644 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -6,7 +6,7 @@ sign_in=登录 sign_in_with=登录方式 sign_out=退出 sign_up=注册 -link_account=链接帐户 +link_account=链接账户 register=注册 website=官方网站 version=当前版本 @@ -778,6 +778,7 @@ webauthn_delete_key_desc=如果删除了安全密钥,则不能再使用它登 manage_account_links=管理绑定过的账号 manage_account_links_desc=这些外部帐户已经绑定到您的 Gitea 帐户。 account_links_not_available=当前没有与您的 Gitea 帐户绑定的外部帐户。 +link_account=链接账户 remove_account_link=删除已绑定的账号 remove_account_link_desc=删除已绑定帐户将吊销其对您的 Gitea 帐户的访问权限。继续? remove_account_link_success=已取消绑定帐户。 From 4a295d4a6cd4597b9a3ebd3cf77ae9ee257629b3 Mon Sep 17 00:00:00 2001 From: Thomas Andrade Date: Tue, 31 May 2022 20:42:19 +0200 Subject: [PATCH 3/7] feat: Add support for extra sshd_config parameters via 'Include' file (#19842) Co-authored-by: techknowlogick --- docker/root/etc/s6/openssh/setup | 1 + docker/root/etc/templates/sshd_config | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docker/root/etc/s6/openssh/setup b/docker/root/etc/s6/openssh/setup index f7843050c170..d4b9b9cd37d3 100755 --- a/docker/root/etc/s6/openssh/setup +++ b/docker/root/etc/s6/openssh/setup @@ -49,6 +49,7 @@ if [ -d /etc/ssh ]; then SSH_DSA_CERT="${SSH_DSA_CERT:+"HostCertificate "}${SSH_DSA_CERT}" \ SSH_MAX_STARTUPS="${SSH_MAX_STARTUPS:+"MaxStartups "}${SSH_MAX_STARTUPS}" \ SSH_MAX_SESSIONS="${SSH_MAX_SESSIONS:+"MaxSessions "}${SSH_MAX_SESSIONS}" \ + SSH_INCLUDE_FILE="${SSH_INCLUDE_FILE:+"Include "}${SSH_INCLUDE_FILE}" \ SSH_LOG_LEVEL=${SSH_LOG_LEVEL:-"INFO"} \ envsubst < /etc/templates/sshd_config > /etc/ssh/sshd_config diff --git a/docker/root/etc/templates/sshd_config b/docker/root/etc/templates/sshd_config index 6f1a3630459a..17c2c397bbb6 100644 --- a/docker/root/etc/templates/sshd_config +++ b/docker/root/etc/templates/sshd_config @@ -41,3 +41,5 @@ Banner none Subsystem sftp /usr/lib/ssh/sftp-server AcceptEnv GIT_PROTOCOL + +${SSH_INCLUDE_FILE} From 40e87d031f60bab8f48d9f0ca91450f8e28b6fbd Mon Sep 17 00:00:00 2001 From: singuliere <35190819+singuliere@users.noreply.github.com> Date: Tue, 31 May 2022 20:42:32 +0200 Subject: [PATCH 4/7] docs: recommendations to ensure backup consistency and reliability (#19845) * docs: recommendations to ensure backup consistency and reliability * s/stooping/stopping/ * Update docs/content/doc/usage/backup-and-restore.en-us.md Co-authored-by: delvh Co-authored-by: delvh --- .../doc/usage/backup-and-restore.en-us.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/content/doc/usage/backup-and-restore.en-us.md b/docs/content/doc/usage/backup-and-restore.en-us.md index a8ad52ae0c99..95e6d376d09d 100644 --- a/docs/content/doc/usage/backup-and-restore.en-us.md +++ b/docs/content/doc/usage/backup-and-restore.en-us.md @@ -22,6 +22,12 @@ file can be unpacked and used to restore an instance. {{< toc >}} +## Backup Consistency + +To ensure the consistency of the Gitea instance, it must be shutdown during backup. + +Gitea consists of a database, files and git repositories, all of which change when it is used. For instance, when a migration is in progress, a transaction is created in the database while the git repository is being copied over. If the backup happens in the middle of the migration, the git repository may be incomplete although the database claims otherwise because it was dumped afterwards. The only way to avoid such race conditions is by stopping the Gitea instance during the backups. + ## Backup Command (`dump`) Switch to the user running Gitea: `su git`. Run `./gitea dump -c /path/to/app.ini` in the Gitea installation @@ -48,6 +54,17 @@ Inside the `gitea-dump-1482906742.zip` file, will be the following: Intermediate backup files are created in a temporary directory specified either with the `--tempdir` command-line parameter or the `TMPDIR` environment variable. +## Backup the database + +The SQL dump created by `gitea dump` uses XORM and Gitea admins may prefer to use the native the MySQL and PostgreSQL dump tools instead. There are still open issues when using XORM for dumping the database that may cause problems when attempting to restore it. + +```sh +# mysql +mysqldump -u$USER -p$PASS --database $DATABASE > gitea-db.sql +# postgres +pgdump -U $USER $DATABASE > gitea-db.sql +``` + ### Using Docker (`dump`) There are a few caveats for using the `dump` command with Docker. From 0e516949a446f509411bcd7b2654a048d37a91c5 Mon Sep 17 00:00:00 2001 From: Gusted Date: Tue, 31 May 2022 18:49:40 +0000 Subject: [PATCH 5/7] Fix inconsistency in doctor output (#19836) * Fix inconsistency in doctor output - Use `logger.Info` instead of `logger.Warn` when no errors were found. * Update modules/doctor/fix16961.go Co-authored-by: delvh Co-authored-by: Lunny Xiao Co-authored-by: delvh Co-authored-by: techknowlogick --- modules/doctor/fix16961.go | 6 +++++- modules/doctor/mergebase.go | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/doctor/fix16961.go b/modules/doctor/fix16961.go index 92c77ba80f29..92c44185055e 100644 --- a/modules/doctor/fix16961.go +++ b/modules/doctor/fix16961.go @@ -302,7 +302,11 @@ func fixBrokenRepoUnits16961(ctx context.Context, logger log.Logger, autofix boo } if !autofix { - logger.Warn("Found %d broken repo_units", count) + if count == 0 { + logger.Info("Found no broken repo_units") + } else { + logger.Warn("Found %d broken repo_units", count) + } return nil } logger.Info("Fixed %d broken repo_units", count) diff --git a/modules/doctor/mergebase.go b/modules/doctor/mergebase.go index 8f5c61a5dab2..61ee9e212bd1 100644 --- a/modules/doctor/mergebase.go +++ b/modules/doctor/mergebase.go @@ -92,12 +92,14 @@ func checkPRMergeBase(ctx context.Context, logger log.Logger, autofix bool) erro if autofix { logger.Info("%d PR mergebases updated of %d PRs total in %d repos", numPRsUpdated, numPRs, numRepos) } else { - if numPRsUpdated > 0 && err == nil { + if numPRsUpdated == 0 { + logger.Info("All %d PRs in %d repos have a correct mergebase", numPRs, numRepos) + } else if err == nil { logger.Critical("%d PRs with incorrect mergebases of %d PRs total in %d repos", numPRsUpdated, numPRs, numRepos) return fmt.Errorf("%d PRs with incorrect mergebases of %d PRs total in %d repos", numPRsUpdated, numPRs, numRepos) + } else { + logger.Warn("%d PRs with incorrect mergebases of %d PRs total in %d repos", numPRsUpdated, numPRs, numRepos) } - - logger.Warn("%d PRs with incorrect mergebases of %d PRs total in %d repos", numPRsUpdated, numPRs, numRepos) } return err From 730b9a5a624651e4821a043fe3f596c92be2df01 Mon Sep 17 00:00:00 2001 From: zeripath Date: Tue, 31 May 2022 21:27:44 +0100 Subject: [PATCH 6/7] Ensure responses are context.ResponseWriters (#19843) In order for web.Wrap to be able to detect if a response has been written we need to wrap any non-context.ResponseWriters as a such. Otherwise responses will be incorrectly detected as non-written to and handlers can double run. In the case of GZip this handler will change the response to a non-context.RW and this failure to correctly detect response writing causes fallthrough and a NPE. Fix #19839 Signed-off-by: Andrew Thornton --- modules/web/wrap_convert.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/web/wrap_convert.go b/modules/web/wrap_convert.go index 8dc4e6d62bd8..b7bcbc64394c 100644 --- a/modules/web/wrap_convert.go +++ b/modules/web/wrap_convert.go @@ -21,6 +21,9 @@ func convertHandler(handler interface{}) wrappedHandlerFunc { case http.HandlerFunc: return func(resp http.ResponseWriter, req *http.Request, others ...wrappedHandlerFunc) (done bool, deferrable func()) { routing.UpdateFuncInfo(req.Context(), funcInfo) + if _, ok := resp.(context.ResponseWriter); !ok { + resp = context.NewResponse(resp) + } t(resp, req) if r, ok := resp.(context.ResponseWriter); ok && r.Status() > 0 { done = true @@ -92,6 +95,9 @@ func convertHandler(handler interface{}) wrappedHandlerFunc { next = wrapInternal(others) } routing.UpdateFuncInfo(req.Context(), funcInfo) + if _, ok := resp.(context.ResponseWriter); !ok { + resp = context.NewResponse(resp) + } t(next).ServeHTTP(resp, req) if r, ok := resp.(context.ResponseWriter); ok && r.Status() > 0 { done = true From d002e3da008ec6945a405e4f14941bd42a341494 Mon Sep 17 00:00:00 2001 From: zeripath Date: Wed, 1 Jun 2022 04:06:31 +0100 Subject: [PATCH 7/7] Fix spelling mistake in ProcReceive (#19853) There was a spelling mistake in the ProcReceive handler. This PR fixes this. --- routers/private/hook_proc_receive.go | 2 +- services/agit/agit.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/routers/private/hook_proc_receive.go b/routers/private/hook_proc_receive.go index e427a55c5616..81dbc1fd1897 100644 --- a/routers/private/hook_proc_receive.go +++ b/routers/private/hook_proc_receive.go @@ -23,7 +23,7 @@ func HookProcReceive(ctx *gitea_context.PrivateContext) { return } - results := agit.ProcRecive(ctx, opts) + results := agit.ProcReceive(ctx, opts) if ctx.Written() { return } diff --git a/services/agit/agit.go b/services/agit/agit.go index 288923618171..cc520dbc7622 100644 --- a/services/agit/agit.go +++ b/services/agit/agit.go @@ -20,8 +20,8 @@ import ( pull_service "code.gitea.io/gitea/services/pull" ) -// ProcRecive handle proc receive work -func ProcRecive(ctx *context.PrivateContext, opts *private.HookOptions) []private.HookProcReceiveRefResult { +// ProcReceive handle proc receive work +func ProcReceive(ctx *context.PrivateContext, opts *private.HookOptions) []private.HookProcReceiveRefResult { // TODO: Add more options? var ( topicBranch string