summaryrefslogtreecommitdiffstats
path: root/cmd/update.go
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-05-21 21:37:13 -0400
committerUnknown <joe2010xtmf@163.com>2014-05-21 21:37:13 -0400
commit5e9a45f74a7f55cde71054255bd8dec8a8037a72 (patch)
tree9e001c14252cec5950c9c93d1ce99f30108aefbf /cmd/update.go
parent1331134316e1165d68d2cb6473e16929ed794dea (diff)
downloadgitea-5e9a45f74a7f55cde71054255bd8dec8a8037a72.tar.gz
gitea-5e9a45f74a7f55cde71054255bd8dec8a8037a72.zip
Code convention
Diffstat (limited to 'cmd/update.go')
-rw-r--r--cmd/update.go34
1 files changed, 3 insertions, 31 deletions
diff --git a/cmd/update.go b/cmd/update.go
index 1ab08ca194..cae492cfb1 100644
--- a/cmd/update.go
+++ b/cmd/update.go
@@ -6,14 +6,12 @@ package cmd
import (
"os"
- "path"
"strconv"
"github.com/codegangsta/cli"
qlog "github.com/qiniu/log"
"github.com/gogits/gogs/models"
- "github.com/gogits/gogs/modules/base"
)
var CmdUpdate = cli.Command{
@@ -24,51 +22,25 @@ var CmdUpdate = cli.Command{
Flags: []cli.Flag{},
}
-func newUpdateLogger(execDir string) {
- logPath := execDir + "/log/update.log"
- os.MkdirAll(path.Dir(logPath), os.ModePerm)
-
- f, err := os.OpenFile(logPath, os.O_WRONLY|os.O_APPEND|os.O_CREATE, os.ModePerm)
- if err != nil {
- qlog.Fatal(err)
- }
-
- qlog.SetOutput(f)
- qlog.Info("Start logging update...")
-}
-
func updateEnv(refName, oldCommitId, newCommitId string) {
os.Setenv("refName", refName)
os.Setenv("oldCommitId", oldCommitId)
os.Setenv("newCommitId", newCommitId)
- qlog.Error("set envs:", refName, oldCommitId, newCommitId)
+ qlog.Info("set envs:", refName, oldCommitId, newCommitId)
}
-// for command: ./gogs update
func runUpdate(c *cli.Context) {
cmd := os.Getenv("SSH_ORIGINAL_COMMAND")
if cmd == "" {
return
}
- execDir, _ := base.ExecDir()
- newUpdateLogger(execDir)
-
- base.NewConfigContext()
- models.LoadModelsConfig()
-
- if models.UseSQLite3 {
- os.Chdir(execDir)
- }
-
- models.SetEngine()
+ setup("log/update.log")
args := c.Args()
if len(args) != 3 {
qlog.Fatal("received less 3 parameters")
- }
-
- if args[0] == "" {
+ } else if args[0] == "" {
qlog.Fatal("refName is empty, shouldn't use")
}