mirror of
https://github.com/gogs/gogs.git
synced 2026-05-07 01:07:15 +02:00
conf: overhaul server settings (#5928)
* conf: rename package * Requires Go 1.12 * Fix lint * Fix lint * Overhaul * db: fix tests * Save my work * Fix tests * Server.UnixSocketPermission * Server.LocalRootURL * SSH settings * Server.OfflineMode * Save my work * App.Version * Remove [server] STATIC_ROOT_PATH * Server.LandingURL
This commit is contained in:
@@ -15,8 +15,8 @@ import (
|
||||
log "unknwon.dev/clog/v2"
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/osutil"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
|
||||
@@ -32,18 +32,18 @@ func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
|
||||
var (
|
||||
hookNames = []string{"pre-receive", "update", "post-receive"}
|
||||
hookTpls = []string{
|
||||
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' pre-receive\n", setting.ScriptType, setting.AppPath, setting.CustomConf),
|
||||
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' update $1 $2 $3\n", setting.ScriptType, setting.AppPath, setting.CustomConf),
|
||||
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' post-receive\n", setting.ScriptType, setting.AppPath, setting.CustomConf),
|
||||
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' pre-receive\n", conf.ScriptType, conf.AppPath(), conf.CustomConf),
|
||||
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' update $1 $2 $3\n", conf.ScriptType, conf.AppPath(), conf.CustomConf),
|
||||
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' post-receive\n", conf.ScriptType, conf.AppPath(), conf.CustomConf),
|
||||
}
|
||||
)
|
||||
|
||||
// Cleanup old update.log and http.log files.
|
||||
filepath.Walk(setting.LogRootPath, func(path string, info os.FileInfo, err error) error {
|
||||
_ = filepath.Walk(conf.LogRootPath, func(path string, info os.FileInfo, err error) error {
|
||||
if !info.IsDir() &&
|
||||
(strings.HasPrefix(filepath.Base(path), "update.log") ||
|
||||
strings.HasPrefix(filepath.Base(path), "http.log")) {
|
||||
os.Remove(path)
|
||||
_ = os.Remove(path)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
@@ -63,7 +63,7 @@ func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
repoBase := filepath.Join(setting.RepoRootPath, strings.ToLower(user.Name), strings.ToLower(repo.Name))
|
||||
repoBase := filepath.Join(conf.RepoRootPath, strings.ToLower(user.Name), strings.ToLower(repo.Name))
|
||||
repoPath := repoBase + ".git"
|
||||
wikiPath := repoBase + ".wiki.git"
|
||||
log.Trace("[%04d]: %s", idx, repoPath)
|
||||
@@ -82,7 +82,7 @@ func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
|
||||
// In case user runs this migration multiple times, and custom hook exists,
|
||||
// we assume it's been migrated already.
|
||||
if hookName != "update" && osutil.IsFile(oldHookPath) && !com.IsExist(customHookDir) {
|
||||
os.MkdirAll(customHookDir, os.ModePerm)
|
||||
_ = os.MkdirAll(customHookDir, os.ModePerm)
|
||||
if err = os.Rename(oldHookPath, newHookPath); err != nil {
|
||||
return fmt.Errorf("move hook file to custom directory '%s' -> '%s': %v", oldHookPath, newHookPath, err)
|
||||
}
|
||||
@@ -93,7 +93,7 @@ func generateAndMigrateGitHooks(x *xorm.Engine) (err error) {
|
||||
}
|
||||
|
||||
if com.IsDir(wikiPath) {
|
||||
os.MkdirAll(wikiHookDir, os.ModePerm)
|
||||
_ = os.MkdirAll(wikiHookDir, os.ModePerm)
|
||||
wikiHookPath := filepath.Join(wikiHookDir, hookName)
|
||||
if err = ioutil.WriteFile(wikiHookPath, []byte(hookTpls[i]), os.ModePerm); err != nil {
|
||||
return fmt.Errorf("write wiki hook file '%s': %v", wikiHookPath, err)
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
func updateRepositorySizes(x *xorm.Engine) (err error) {
|
||||
@@ -60,7 +60,7 @@ func updateRepositorySizes(x *xorm.Engine) (err error) {
|
||||
continue
|
||||
}
|
||||
|
||||
repoPath := filepath.Join(setting.RepoRootPath, strings.ToLower(user.Name), strings.ToLower(repo.Name)) + ".git"
|
||||
repoPath := filepath.Join(conf.RepoRootPath, strings.ToLower(user.Name), strings.ToLower(repo.Name)) + ".git"
|
||||
countObject, err := git.GetRepoSize(repoPath)
|
||||
if err != nil {
|
||||
log.Warn("GetRepoSize: %v", err)
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"xorm.io/xorm"
|
||||
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
func updateRepositoryDescriptionField(x *xorm.Engine) error {
|
||||
@@ -20,13 +20,13 @@ func updateRepositoryDescriptionField(x *xorm.Engine) error {
|
||||
return nil
|
||||
}
|
||||
switch {
|
||||
case setting.UseMySQL:
|
||||
case conf.UseMySQL:
|
||||
_, err = x.Exec("ALTER TABLE `repository` MODIFY `description` VARCHAR(512);")
|
||||
case setting.UseMSSQL:
|
||||
case conf.UseMSSQL:
|
||||
_, err = x.Exec("ALTER TABLE `repository` ALTER COLUMN `description` VARCHAR(512);")
|
||||
case setting.UsePostgreSQL:
|
||||
case conf.UsePostgreSQL:
|
||||
_, err = x.Exec("ALTER TABLE `repository` ALTER COLUMN `description` TYPE VARCHAR(512);")
|
||||
case setting.UseSQLite3:
|
||||
case conf.UseSQLite3:
|
||||
// Sqlite3 uses TEXT type by default for any string type field.
|
||||
// Keep this comment to mention that we don't missed any option.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user