From 5a05d6633d413b1c5182a0a542e173f99601a103 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 7 Mar 2014 17:22:15 -0500 Subject: [PATCH] Merge utils to modules --- bee.json | 2 +- gogs.go | 6 +++--- models/models.go | 18 +++++++++--------- models/repo.go | 3 ++- models/user.go | 6 +++--- modules/auth/form.go | 2 +- modules/auth/user.go | 2 +- {utils => modules/base}/conf.go | 2 +- {utils => modules/base}/tool.go | 2 +- {utils => modules}/log/log.go | 0 routers/repo/repo.go | 2 +- routers/user/ssh.go | 2 +- routers/user/user.go | 2 +- web.go | 11 +++++------ 14 files changed, 30 insertions(+), 30 deletions(-) rename {utils => modules/base}/conf.go (98%) rename {utils => modules/base}/tool.go (96%) rename {utils => modules}/log/log.go (100%) diff --git a/bee.json b/bee.json index e4a0f803d3..de211f7277 100644 --- a/bee.json +++ b/bee.json @@ -11,7 +11,7 @@ "controllers": "routers", "models": "", "others": [ - "utils", "modules", + "modules", "$GOPATH/src/github.com/gogits/binding" ] }, diff --git a/gogs.go b/gogs.go index 7bbcd803e5..552a4db272 100644 --- a/gogs.go +++ b/gogs.go @@ -11,7 +11,7 @@ import ( "runtime" "github.com/codegangsta/cli" - "github.com/gogits/gogs/utils" + "github.com/gogits/gogs/modules/base" ) // +build go1.1 @@ -31,12 +31,12 @@ func checkRunUser() bool { // TODO: log return false } - return user.Username == utils.Cfg.MustValue("", "RUN_USER") + return user.Username == base.Cfg.MustValue("", "RUN_USER") } func main() { /*if !checkRunUser() { - println("The command should be run as", utils.Cfg.MustValue("", "RUN_USER")) + println("The command should be run as", base.Cfg.MustValue("", "RUN_USER")) return }*/ diff --git a/models/models.go b/models/models.go index 0dee65478f..e0ab3ca15a 100644 --- a/models/models.go +++ b/models/models.go @@ -12,7 +12,7 @@ import ( _ "github.com/go-sql-driver/mysql" "github.com/lunny/xorm" - "github.com/gogits/gogs/utils" + "github.com/gogits/gogs/modules/base" ) var ( @@ -41,11 +41,11 @@ type Comment struct { } func setEngine() { - dbType := utils.Cfg.MustValue("database", "DB_TYPE") - dbHost := utils.Cfg.MustValue("database", "HOST") - dbName := utils.Cfg.MustValue("database", "NAME") - dbUser := utils.Cfg.MustValue("database", "USER") - dbPwd := utils.Cfg.MustValue("database", "PASSWD") + dbType := base.Cfg.MustValue("database", "DB_TYPE") + dbHost := base.Cfg.MustValue("database", "HOST") + dbName := base.Cfg.MustValue("database", "NAME") + dbUser := base.Cfg.MustValue("database", "USER") + dbPwd := base.Cfg.MustValue("database", "PASSWD") uname, err := user.Current() if err != nil { @@ -54,7 +54,7 @@ func setEngine() { } if uname.Username == "jiahuachen" { - dbPwd = utils.Cfg.MustValue("database", "PASSWD_jiahua") + dbPwd = base.Cfg.MustValue("database", "PASSWD_jiahua") } switch dbType { @@ -82,9 +82,9 @@ func setEngine() { //log.Trace("Initialized database -> %s", dbName) - RepoRootPath = utils.Cfg.MustValue("repository", "ROOT") + RepoRootPath = base.Cfg.MustValue("repository", "ROOT") if uname.Username == "jiahuachen" { - RepoRootPath = utils.Cfg.MustValue("repository", "ROOT_jiahuachen") + RepoRootPath = base.Cfg.MustValue("repository", "ROOT_jiahuachen") } } diff --git a/models/repo.go b/models/repo.go index 04e8c75c1b..22b98e7975 100644 --- a/models/repo.go +++ b/models/repo.go @@ -10,8 +10,9 @@ import ( "strings" "time" - "github.com/gogits/gogs/utils/log" git "github.com/libgit2/git2go" + + "github.com/gogits/gogs/modules/log" ) type Repo struct { diff --git a/models/user.go b/models/user.go index 36cdfc8a43..d904304f51 100644 --- a/models/user.go +++ b/models/user.go @@ -14,13 +14,13 @@ import ( "github.com/dchest/scrypt" - "github.com/gogits/gogs/utils" + "github.com/gogits/gogs/modules/base" ) var UserPasswdSalt string func init() { - UserPasswdSalt = utils.Cfg.MustValue("security", "USER_PASSWD_SALT") + UserPasswdSalt = base.Cfg.MustValue("security", "USER_PASSWD_SALT") } // User types. @@ -115,7 +115,7 @@ func RegisterUser(user *User) (err error) { } user.LowerName = strings.ToLower(user.Name) - user.Avatar = utils.EncodeMd5(user.Email) + user.Avatar = base.EncodeMd5(user.Email) if err = user.EncodePasswd(); err != nil { return err } diff --git a/modules/auth/form.go b/modules/auth/form.go index 98c558399f..a90f3d8542 100644 --- a/modules/auth/form.go +++ b/modules/auth/form.go @@ -14,7 +14,7 @@ import ( "github.com/gogits/binding" "github.com/gogits/gogs/modules/base" - "github.com/gogits/gogs/utils/log" + "github.com/gogits/gogs/modules/log" ) type Form interface { diff --git a/modules/auth/user.go b/modules/auth/user.go index e25593b737..215cffedb0 100644 --- a/modules/auth/user.go +++ b/modules/auth/user.go @@ -11,7 +11,7 @@ import ( "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/base" - "github.com/gogits/gogs/utils/log" + "github.com/gogits/gogs/modules/log" ) func SignedInId(session sessions.Session) int64 { diff --git a/utils/conf.go b/modules/base/conf.go similarity index 98% rename from utils/conf.go rename to modules/base/conf.go index 75bd2462d6..19e9d689c2 100644 --- a/utils/conf.go +++ b/modules/base/conf.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package utils +package base import ( "fmt" diff --git a/utils/tool.go b/modules/base/tool.go similarity index 96% rename from utils/tool.go rename to modules/base/tool.go index 1d2db4bcfd..eef473f965 100644 --- a/utils/tool.go +++ b/modules/base/tool.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package utils +package base import ( "crypto/md5" diff --git a/utils/log/log.go b/modules/log/log.go similarity index 100% rename from utils/log/log.go rename to modules/log/log.go diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 6ff949b90f..e9ad7d1ab4 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -15,7 +15,7 @@ import ( "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/base" - "github.com/gogits/gogs/utils/log" + "github.com/gogits/gogs/modules/log" ) func Create(req *http.Request, r render.Render, data base.TmplData, session sessions.Session) { diff --git a/routers/user/ssh.go b/routers/user/ssh.go index 6589753529..34c378061b 100644 --- a/routers/user/ssh.go +++ b/routers/user/ssh.go @@ -13,7 +13,7 @@ import ( "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/base" - "github.com/gogits/gogs/utils/log" + "github.com/gogits/gogs/modules/log" ) func AddPublicKey(req *http.Request, data base.TmplData, r render.Render, session sessions.Session) { diff --git a/routers/user/user.go b/routers/user/user.go index 7eac9b7429..a07d79e454 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -14,7 +14,7 @@ import ( "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/base" - "github.com/gogits/gogs/utils/log" + "github.com/gogits/gogs/modules/log" ) func Dashboard(r render.Render, data base.TmplData, session sessions.Session) { diff --git a/web.go b/web.go index fa889ba1aa..2b6041b123 100644 --- a/web.go +++ b/web.go @@ -18,11 +18,10 @@ import ( "github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/base" + "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/routers" "github.com/gogits/gogs/routers/repo" "github.com/gogits/gogs/routers/user" - "github.com/gogits/gogs/utils" - "github.com/gogits/gogs/utils/log" ) var CmdWeb = cli.Command{ @@ -39,7 +38,7 @@ gogs web`, var AppHelpers template.FuncMap = map[string]interface{}{ "AppName": func() string { - return utils.Cfg.MustValue("", "APP_NAME") + return base.Cfg.MustValue("", "APP_NAME") }, "AppVer": func() string { return APP_VER @@ -47,7 +46,7 @@ var AppHelpers template.FuncMap = map[string]interface{}{ } func runWeb(*cli.Context) { - log.Info("%s %s", utils.Cfg.MustValue("", "APP_NAME"), APP_VER) + log.Info("%s %s", base.Cfg.MustValue("", "APP_NAME"), APP_VER) m := martini.Classic() @@ -75,8 +74,8 @@ func runWeb(*cli.Context) { m.Any("/repo/list", auth.SignInRequire(false), repo.List) listenAddr := fmt.Sprintf("%s:%s", - utils.Cfg.MustValue("server", "HTTP_ADDR"), - utils.Cfg.MustValue("server", "HTTP_PORT", "3000")) + base.Cfg.MustValue("server", "HTTP_ADDR"), + base.Cfg.MustValue("server", "HTTP_PORT", "3000")) log.Info("Listen: %s", listenAddr) http.ListenAndServe(listenAddr, m) }