bug fixed

This commit is contained in:
Lunny Xiao 2014-04-10 23:02:08 +08:00
parent 88d873c67f
commit a24c0b92e4
2 changed files with 44 additions and 34 deletions

View file

@ -82,7 +82,8 @@ func Http(ctx *middleware.Context, params martini.Params) {
return return
} }
newUser := &models.User{Passwd: passwd} newUser := &models.User{Passwd: passwd, Salt: authUser.Salt}
newUser.EncodePasswd() newUser.EncodePasswd()
if authUser.Passwd != newUser.Passwd { if authUser.Passwd != newUser.Passwd {
ctx.Handle(401, "no basic auth and digit auth", nil) ctx.Handle(401, "no basic auth and digit auth", nil)
@ -112,7 +113,10 @@ func Http(ctx *middleware.Context, params martini.Params) {
} }
} }
config := Config{base.RepoRootPath, "git", true, true} config := Config{base.RepoRootPath, "git", true, true, func(rpc string, input []byte) {
//fmt.Println("rpc:", rpc)
//fmt.Println("input:", string(input))
}}
handler := HttpBackend(&config) handler := HttpBackend(&config)
handler(ctx.ResponseWriter, ctx.Req) handler(ctx.ResponseWriter, ctx.Req)
@ -139,7 +143,7 @@ type Config struct {
GitBinPath string GitBinPath string
UploadPack bool UploadPack bool
ReceivePack bool ReceivePack bool
OnPushSucceed func() OnSucceed func(rpc string, input []byte)
} }
type handler struct { type handler struct {
@ -243,7 +247,9 @@ func serviceRpc(rpc string, hr handler) {
io.Copy(w, stdout) io.Copy(w, stdout)
cmd.Wait() cmd.Wait()
hr.Config.OnPushSucceed() if hr.Config.OnSucceed != nil {
hr.Config.OnSucceed(rpc, input)
}
} }
func getInfoRefs(hr handler) { func getInfoRefs(hr handler) {

View file

@ -42,32 +42,7 @@ func newUpdateLogger(execDir string) {
qlog.Info("Start logging update...") qlog.Info("Start logging update...")
} }
// for command: ./gogs update func update(refName, oldCommitId, newCommitId string) {
func runUpdate(c *cli.Context) {
execDir, _ := base.ExecDir()
newUpdateLogger(execDir)
base.NewConfigContext()
models.LoadModelsConfig()
if models.UseSQLite3 {
os.Chdir(execDir)
}
models.SetEngine()
args := c.Args()
if len(args) != 3 {
qlog.Fatal("received less 3 parameters")
}
refName := args[0]
if refName == "" {
qlog.Fatal("refName is empty, shouldn't use")
}
oldCommitId := args[1]
newCommitId := args[2]
isNew := strings.HasPrefix(oldCommitId, "0000000") isNew := strings.HasPrefix(oldCommitId, "0000000")
if isNew && if isNew &&
strings.HasPrefix(newCommitId, "0000000") { strings.HasPrefix(newCommitId, "0000000") {
@ -158,3 +133,32 @@ func runUpdate(c *cli.Context) {
qlog.Fatalf("runUpdate.models.CommitRepoAction: %v", err) qlog.Fatalf("runUpdate.models.CommitRepoAction: %v", err)
} }
} }
// for command: ./gogs update
func runUpdate(c *cli.Context) {
execDir, _ := base.ExecDir()
newUpdateLogger(execDir)
base.NewConfigContext()
models.LoadModelsConfig()
if models.UseSQLite3 {
os.Chdir(execDir)
}
models.SetEngine()
args := c.Args()
if len(args) != 3 {
qlog.Fatal("received less 3 parameters")
}
refName := args[0]
if refName == "" {
qlog.Fatal("refName is empty, shouldn't use")
}
oldCommitId := args[1]
newCommitId := args[2]
update(refName, oldCommitId, newCommitId)
}