mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-26 06:16:56 +09:00
Adds a repository setting for the default squash merge commit message body with GitHub's options `PR_BODY`, `COMMIT_MESSAGES` and `BLANK`, also settable via `squash_merge_commit_message` in the API. The commit title stays the pull request title. 1. Breaking: API squash merges without `merge_message_field` now get the same default message as the web merge box instead of a title-only commit, which affects clients sending only `Do` like Renovate. An empty value keeps title-only. 2. Breaking: `[repository.pull-request] DEFAULT_SQUASH_MERGE_MESSAGE` replaces `POPULATE_SQUASH_COMMENT_WITH_COMMIT_MESSAGES`, which still works as a deprecated fallback. Repositories store the default when created or next saved. 3. Deprecated app.ini keys now migrate through one table instead of per-loader fallbacks, which also fixes the ignored `[mailer] CERT_FILE` and `KEY_FILE` fallbacks. Deprecation warnings no longer claim a removal version. <img width="1891" height="571" alt="grafik" src="https://github.com/user-attachments/assets/0fdcde13-1f11-4156-b598-d80eb0d04cbe" /> --------- Co-authored-by: silverwind <me@silverwind.io>
65 lines
3.0 KiB
Go
65 lines
3.0 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package setting
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"gitea.dev/modules/util"
|
|
)
|
|
|
|
type deprecatedKey struct {
|
|
oldSection, oldKey, newSection, newKey string
|
|
convert func(old ConfigKey) string
|
|
}
|
|
|
|
func invertBool(old ConfigKey) string {
|
|
return strconv.FormatBool(!old.MustBool())
|
|
}
|
|
|
|
// keep rows, users upgrading from older versions still need them
|
|
var deprecatedKeys = []deprecatedKey{
|
|
{"server", "LFS_CONTENT_PATH", "lfs", "PATH", nil},
|
|
{"server", "ENABLE_LETSENCRYPT", "server", "ENABLE_ACME", nil},
|
|
{"server", "LETSENCRYPT_ACCEPTTOS", "server", "ACME_ACCEPTTOS", nil},
|
|
{"server", "LETSENCRYPT_DIRECTORY", "server", "ACME_DIRECTORY", nil},
|
|
{"server", "LETSENCRYPT_EMAIL", "server", "ACME_EMAIL", nil},
|
|
{"mailer", "MAILER_TYPE", "mailer", "PROTOCOL", func(old ConfigKey) string { return old.In("", []string{"sendmail"}) }},
|
|
{"mailer", "IS_TLS_ENABLED", "mailer", "PROTOCOL", func(old ConfigKey) string { return util.Iif(old.MustBool(), "smtps", "smtp+starttls") }},
|
|
{"mailer", "DISABLE_HELO", "mailer", "ENABLE_HELO", invertBool},
|
|
{"mailer", "SKIP_VERIFY", "mailer", "FORCE_TRUST_SERVER_CERT", nil},
|
|
{"mailer", "USE_CERTIFICATE", "mailer", "USE_CLIENT_CERT", nil},
|
|
{"mailer", "CERT_FILE", "mailer", "CLIENT_CERT_FILE", nil},
|
|
{"mailer", "KEY_FILE", "mailer", "CLIENT_KEY_FILE", nil},
|
|
{"mailer", "ENABLE_HTML_ALTERNATIVE", "mailer", "SEND_AS_PLAIN_TEXT", invertBool},
|
|
{"repository", "DISABLE_MIRRORS", "mirror", "DISABLE_NEW_PULL", nil},
|
|
{"git.reflog", "ENABLED", "git.config", "core.logAllRefUpdates", func(old ConfigKey) string { return old.In("true", []string{"true", "false"}) }},
|
|
{"git.reflog", "EXPIRATION", "git.config", "gc.reflogExpire", func(old ConfigKey) string { return old.String() + ".days" }},
|
|
{"oauth2", "ENABLE", "oauth2", "ENABLED", nil},
|
|
{"cors", "X_FRAME_OPTIONS", "security", "X_FRAME_OPTIONS", nil},
|
|
{"repository.pull-request", "POPULATE_SQUASH_COMMENT_WITH_COMMIT_MESSAGES", "repository.pull-request", "DEFAULT_SQUASH_MERGE_MESSAGE", func(old ConfigKey) string { return util.Iif(old.MustBool(), "COMMIT_MESSAGES", "PR_BODY") }},
|
|
}
|
|
|
|
// applyDeprecatedKeys copies each deprecated key of the table to its replacement unless the replacement is present
|
|
func applyDeprecatedKeys(rootCfg ConfigProvider) {
|
|
for _, deprecated := range deprecatedKeys {
|
|
oldSec, _ := rootCfg.GetSection(deprecated.oldSection)
|
|
if oldSec == nil || !oldSec.HasKey(deprecated.oldKey) {
|
|
continue
|
|
}
|
|
deprecatedSetting(rootCfg, deprecated.oldSection, deprecated.oldKey, deprecated.newSection, deprecated.newKey)
|
|
if newSec, _ := rootCfg.GetSection(deprecated.newSection); newSec != nil && newSec.HasKey(deprecated.newKey) {
|
|
continue
|
|
}
|
|
oldKey := oldSec.Key(deprecated.oldKey)
|
|
value := oldKey.String()
|
|
if deprecated.convert != nil {
|
|
value = deprecated.convert(oldKey)
|
|
}
|
|
if value != "" {
|
|
_, _ = rootCfg.Section(deprecated.newSection).NewKey(deprecated.newKey, value)
|
|
}
|
|
}
|
|
}
|