From ce350a737a63aeb4e2ca5924adf28862a6a6cfb1 Mon Sep 17 00:00:00 2001 From: skyblue Date: Sat, 5 Apr 2014 22:46:32 +0800 Subject: [PATCH 1/4] update models, add licence in start.sh --- models/models.go | 17 +++++++++++------ start.sh | 4 ++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/models/models.go b/models/models.go index 384f1fc42..0dc4d51e7 100644 --- a/models/models.go +++ b/models/models.go @@ -18,7 +18,9 @@ import ( ) var ( - orm *xorm.Engine + orm *xorm.Engine + tables []interface{} + HasEngine bool DbCfg struct { @@ -28,6 +30,11 @@ var ( UseSQLite3 bool ) +func init() { + tables = append(tables, new(User), new(PublicKey), new(Repository), new(Watch), + new(Action), new(Access), new(Issue), new(Comment)) +} + func LoadModelsConfig() { DbCfg.Type = base.Cfg.MustValue("database", "DB_TYPE") if DbCfg.Type == "sqlite3" { @@ -58,9 +65,7 @@ func NewTestEngine(x *xorm.Engine) (err error) { if err != nil { return fmt.Errorf("models.init(fail to conntect database): %v\n", err) } - - return x.Sync(new(User), new(PublicKey), new(Repository), new(Watch), - new(Action), new(Access), new(Issue), new(Comment)) + return x.Sync(tables...) } func SetEngine() (err error) { @@ -102,8 +107,8 @@ func SetEngine() (err error) { func NewEngine() (err error) { if err = SetEngine(); err != nil { return err - } else if err = orm.Sync(new(User), new(PublicKey), new(Repository), new(Watch), - new(Action), new(Access), new(Issue), new(Comment)); err != nil { + } + if err = orm.Sync(tables...); err != nil { return fmt.Errorf("sync database struct error: %v\n", err) } return nil diff --git a/start.sh b/start.sh index 331d340cd..b0c9af505 100755 --- a/start.sh +++ b/start.sh @@ -1,5 +1,9 @@ #!/bin/bash - # +# Copyright 2014 The Gogs Authors. All rights reserved. +# Use of this source code is governed by a MIT-style +# license that can be found in the LICENSE file. +# # start gogs web # cd "$(dirname $0)" From a04918e36d49e1d066c6f661a73eebf706a97237 Mon Sep 17 00:00:00 2001 From: skyblue Date: Sun, 6 Apr 2014 23:12:19 +0800 Subject: [PATCH 2/4] add fswatch.json for hot compile --- .fswatch.json | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .fswatch.json diff --git a/.fswatch.json b/.fswatch.json new file mode 100644 index 000000000..f84e30356 --- /dev/null +++ b/.fswatch.json @@ -0,0 +1,22 @@ +{ + "paths": [ + "." + ], + "depth": 2, + "exclude": [ + "^gogs$", + "~$", + "\\.swp$", + "\\.exe$", + "\\.swx$", + ".*\\.log$" + ], + "include": [], + "command": [ + "bash", "-c", "go build && ./gogs web" + ], + "env": { + "PROGRAM": "fswatch" + }, + "enable-restart": false +} From 7a4c6c22ce1e79d0f0c97ab9c5deae73020bd11c Mon Sep 17 00:00:00 2001 From: skyblue Date: Mon, 7 Apr 2014 00:11:18 +0800 Subject: [PATCH 3/4] fix start.sh in crontab run failed problem --- start.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/start.sh b/start.sh index b0c9af505..3b974378e 100755 --- a/start.sh +++ b/start.sh @@ -1,10 +1,15 @@ -#!/bin/bash - -# +#!/bin/sh - # Copyright 2014 The Gogs Authors. All rights reserved. # Use of this source code is governed by a MIT-style # license that can be found in the LICENSE file. # # start gogs web # -cd "$(dirname $0)" -./gogs web +IFS=' + ' +PATH=/bin:/usr/bin:/usr/local/bin +HOME=${HOME:?"need \$HOME variable"} +USER=$(whoami) +export USER HOME PATH + +cd "$(dirname $0)" && exec ./gogs web From 583f11f27cb6d5d04a5198c6d4514a4da3cae92a Mon Sep 17 00:00:00 2001 From: skyblue Date: Mon, 7 Apr 2014 00:19:59 +0800 Subject: [PATCH 4/4] better looks on github --- .fswatch.json | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.fswatch.json b/.fswatch.json index f84e30356..81243ebc3 100644 --- a/.fswatch.json +++ b/.fswatch.json @@ -1,22 +1,20 @@ { - "paths": [ - "." - ], + "paths": ["."], "depth": 2, "exclude": [ - "^gogs$", + "^gogs$", "~$", "\\.swp$", "\\.exe$", - "\\.swx$", - ".*\\.log$" + "\\.swx$", + ".*\\.log$" ], - "include": [], + "include": ["\\.go$"], "command": [ "bash", "-c", "go build && ./gogs web" ], "env": { - "PROGRAM": "fswatch" + "POWERED_BY": "github.com/shxsun/fswatch" }, "enable-restart": false }