aboutsummaryrefslogtreecommitdiff
path: root/internal/db/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'internal/db/migrations')
-rw-r--r--internal/db/migrations/v15.go18
-rw-r--r--internal/db/migrations/v16.go4
-rw-r--r--internal/db/migrations/v18.go10
3 files changed, 16 insertions, 16 deletions
diff --git a/internal/db/migrations/v15.go b/internal/db/migrations/v15.go
index 0ef77555..72d24143 100644
--- a/internal/db/migrations/v15.go
+++ b/internal/db/migrations/v15.go
@@ -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)
diff --git a/internal/db/migrations/v16.go b/internal/db/migrations/v16.go
index b2eb813b..91bf4925 100644
--- a/internal/db/migrations/v16.go
+++ b/internal/db/migrations/v16.go
@@ -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)
diff --git a/internal/db/migrations/v18.go b/internal/db/migrations/v18.go
index 9ebb46ed..ceeb5c7a 100644
--- a/internal/db/migrations/v18.go
+++ b/internal/db/migrations/v18.go
@@ -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.
}