forked from NYANDEV/forgejo
Merge branch 'dev' of github.com:gogits/gogs into dev
This commit is contained in:
commit
cd5b800a21
4 changed files with 45 additions and 11 deletions
20
.fswatch.json
Normal file
20
.fswatch.json
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"paths": ["."],
|
||||
"depth": 2,
|
||||
"exclude": [
|
||||
"^gogs$",
|
||||
"~$",
|
||||
"\\.swp$",
|
||||
"\\.exe$",
|
||||
"\\.swx$",
|
||||
".*\\.log$"
|
||||
],
|
||||
"include": ["\\.go$"],
|
||||
"command": [
|
||||
"bash", "-c", "go build && ./gogs web"
|
||||
],
|
||||
"env": {
|
||||
"POWERED_BY": "github.com/shxsun/fswatch"
|
||||
},
|
||||
"enable-restart": false
|
||||
}
|
|
@ -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), new(Oauth2))
|
||||
}
|
||||
|
||||
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", 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,9 +107,9 @@ 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 {
|
||||
return fmt.Errorf("sync database struct error: %v", err)
|
||||
}
|
||||
if err = orm.Sync(tables...); err != nil {
|
||||
return fmt.Errorf("sync database struct error: %v\n", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
15
start.sh
15
start.sh
|
@ -1,6 +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
|
||||
|
|
2
web.go
2
web.go
|
@ -88,7 +88,7 @@ func runWeb(*cli.Context) {
|
|||
m.Get("/avatar/:hash", avt.ServeHTTP)
|
||||
|
||||
m.Group("/user", func(r martini.Router) {
|
||||
// r.Any("/login/github", user.SocialSignIn)
|
||||
r.Any("/login/github", user.SocialSignIn)
|
||||
r.Any("/login", binding.BindIgnErr(auth.LogInForm{}), user.SignIn)
|
||||
r.Any("/sign_up", binding.BindIgnErr(auth.RegisterForm{}), user.SignUp)
|
||||
r.Any("/forget_password", user.ForgotPasswd)
|
||||
|
|
Loading…
Reference in a new issue