release/v1.15
Unknown 2014-07-12 00:55:19 -04:00
parent 63cc14062a
commit 0f907301b7
9 changed files with 48 additions and 15 deletions

View File

@ -11,6 +11,7 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"path" "path"
"runtime"
"strings" "strings"
"github.com/codegangsta/cli" "github.com/codegangsta/cli"
@ -93,9 +94,16 @@ func rewriteAuthorizedKeys(sshPath, oldPath, newPath string) error {
} }
func rewriteUpdateHook(path, appPath string) error { func rewriteUpdateHook(path, appPath string) error {
if runtime.GOOS == "windows" {
rp := strings.NewReplacer("\\", "/")
appPath = "\"" + rp.Replace(appPath) + "\""
} else {
rp := strings.NewReplacer("\\", "/", " ", "\\ ") rp := strings.NewReplacer("\\", "/", " ", "\\ ")
appPath = rp.Replace(appPath)
}
if err := ioutil.WriteFile(path, []byte(fmt.Sprintf(models.TPL_UPDATE_HOOK, if err := ioutil.WriteFile(path, []byte(fmt.Sprintf(models.TPL_UPDATE_HOOK,
setting.ScriptType, rp.Replace(appPath))), os.ModePerm); err != nil { setting.ScriptType, appPath)), os.ModePerm); err != nil {
return err return err
} }
return nil return nil

View File

@ -103,7 +103,10 @@ func runWeb(*cli.Context) {
r.Post("/markdown/raw", v1.MarkdownRaw) r.Post("/markdown/raw", v1.MarkdownRaw)
// Users. // Users.
r.Get("/users/search", v1.SearchUser) r.Get("/users/search", v1.SearchUsers)
// Repositories.
r.Get("/orgs/:org/repos/search", v1.SearchOrgRepositoreis)
r.Any("**", func(ctx *middleware.Context) { r.Any("**", func(ctx *middleware.Context) {
ctx.JSON(404, &base.ApiJsonErr{"Not Found", v1.DOC_URL}) ctx.JSON(404, &base.ApiJsonErr{"Not Found", v1.DOC_URL})
@ -182,6 +185,8 @@ func runWeb(*cli.Context) {
r.Get("/:authid/delete", admin.DeleteAuthSource) r.Get("/:authid/delete", admin.DeleteAuthSource)
}, adminReq) }, adminReq)
m.Get("/:username", ignSignIn, user.Profile)
if martini.Env == martini.Dev { if martini.Env == martini.Dev {
m.Get("/template/**", dev.TemplatePreview) m.Get("/template/**", dev.TemplatePreview)
dev.RegisterDebugRoutes(m) dev.RegisterDebugRoutes(m)

View File

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
) )
const APP_VER = "0.4.5.0707 Alpha" const APP_VER = "0.4.5.0712 Alpha"
func init() { func init() {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())

View File

@ -11,6 +11,7 @@ import (
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
"runtime"
"sort" "sort"
"strings" "strings"
"time" "time"
@ -359,11 +360,17 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep
return err return err
} }
if runtime.GOOS == "windows" {
rp := strings.NewReplacer("\\", "/")
appPath = "\"" + rp.Replace(appPath) + "\""
} else {
rp := strings.NewReplacer("\\", "/", " ", "\\ ") rp := strings.NewReplacer("\\", "/", " ", "\\ ")
appPath = rp.Replace(appPath)
}
// hook/post-update // hook/post-update
if err := createHookUpdate(filepath.Join(repoPath, "hooks", "update"), if err := createHookUpdate(filepath.Join(repoPath, "hooks", "update"),
fmt.Sprintf(TPL_UPDATE_HOOK, setting.ScriptType, fmt.Sprintf(TPL_UPDATE_HOOK, setting.ScriptType, appPath)); err != nil {
rp.Replace(appPath))); err != nil {
return err return err
} }

View File

@ -500,7 +500,7 @@ func SearchUserByName(key string, limit int) (us []*User, err error) {
key = strings.ToLower(key) key = strings.ToLower(key)
us = make([]*User, 0, limit) us = make([]*User, 0, limit)
err = x.Limit(limit).Where("lower_name like '%" + key + "%'").Find(&us) err = x.Limit(limit).Where("type=0").And("lower_name like '%" + key + "%'").Find(&us)
return us, err return us, err
} }

View File

@ -163,7 +163,7 @@ func Users(ctx *middleware.Context) {
if p < 1 { if p < 1 {
p = 1 p = 1
} }
pageNum := 100 pageNum := 50
count := models.CountUsers() count := models.CountUsers()
curCount := int64((p-1)*pageNum + pageNum) curCount := int64((p-1)*pageNum + pageNum)
if curCount > count { if curCount > count {
@ -192,7 +192,7 @@ func Repositories(ctx *middleware.Context) {
if p < 1 { if p < 1 {
p = 1 p = 1
} }
pageNum := 2 pageNum := 50
count := models.CountRepositories() count := models.CountRepositories()
curCount := int64((p-1)*pageNum + pageNum) curCount := int64((p-1)*pageNum + pageNum)
if curCount > count { if curCount > count {

View File

@ -0,0 +1,13 @@
// 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.
package v1
import (
"github.com/gogits/gogs/modules/middleware"
)
func SearchOrgRepositoreis(ctx *middleware.Context) {
}

View File

@ -15,7 +15,7 @@ type user struct {
AvatarLink string `json:"avatar"` AvatarLink string `json:"avatar"`
} }
func SearchUser(ctx *middleware.Context) { func SearchUsers(ctx *middleware.Context) {
q := ctx.Query("q") q := ctx.Query("q")
limit, err := base.StrTo(ctx.Query("limit")).Int() limit, err := base.StrTo(ctx.Query("limit")).Int()
if err != nil { if err != nil {

View File

@ -47,13 +47,13 @@ func SettingPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
if ctx.User.Name != form.UserName { if ctx.User.Name != form.UserName {
isExist, err := models.IsUserExist(form.UserName) isExist, err := models.IsUserExist(form.UserName)
if err != nil { if err != nil {
ctx.Handle(500, "user.Setting(update: check existence)", err) ctx.Handle(500, "user.SettingPost(update: check existence)", err)
return return
} else if isExist { } else if isExist {
ctx.RenderWithErr("User name has been taken.", "user/setting", &form) ctx.RenderWithErr("User name has been taken.", SETTING, &form)
return return
} else if err = models.ChangeUserName(ctx.User, form.UserName); err != nil { } else if err = models.ChangeUserName(ctx.User, form.UserName); err != nil {
ctx.Handle(500, "user.Setting(change user name)", err) ctx.Handle(500, "user.SettingPost(change user name)", err)
return return
} }
log.Trace("%s User name changed: %s -> %s", ctx.Req.RequestURI, ctx.User.Name, form.UserName) log.Trace("%s User name changed: %s -> %s", ctx.Req.RequestURI, ctx.User.Name, form.UserName)
@ -68,7 +68,7 @@ func SettingPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
ctx.User.Avatar = base.EncodeMd5(form.Avatar) ctx.User.Avatar = base.EncodeMd5(form.Avatar)
ctx.User.AvatarEmail = form.Avatar ctx.User.AvatarEmail = form.Avatar
if err := models.UpdateUser(ctx.User); err != nil { if err := models.UpdateUser(ctx.User); err != nil {
ctx.Handle(500, "setting.Setting(UpdateUser)", err) ctx.Handle(500, "setting.SettingPost(UpdateUser)", err)
return return
} }
log.Trace("%s User setting updated: %s", ctx.Req.RequestURI, ctx.User.LowerName) log.Trace("%s User setting updated: %s", ctx.Req.RequestURI, ctx.User.LowerName)