From 7ffdabb28f65b9e4414cd19c0c1f1a400b16b1f3 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 6 Jul 2014 18:25:07 -0400 Subject: Move debug router location --- .gitignore | 1 - cmd/web.go | 4 +--- models/issue.go | 5 ++++- routers/debug/debug.go | 16 ---------------- routers/debug/ignored.go | 11 ----------- routers/dev/debug.go | 18 ++++++++++++++++++ 6 files changed, 23 insertions(+), 32 deletions(-) delete mode 100644 routers/debug/debug.go delete mode 100644 routers/debug/ignored.go create mode 100644 routers/dev/debug.go diff --git a/.gitignore b/.gitignore index 65252f8c..f8d8a286 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,6 @@ public/img/avatar/ *.o *.a *.so -dev # Folders _obj diff --git a/cmd/web.go b/cmd/web.go index 3ee38f76..5f9c168d 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -26,7 +26,6 @@ import ( "github.com/gogits/gogs/routers" "github.com/gogits/gogs/routers/admin" "github.com/gogits/gogs/routers/api/v1" - "github.com/gogits/gogs/routers/debug" "github.com/gogits/gogs/routers/dev" "github.com/gogits/gogs/routers/org" "github.com/gogits/gogs/routers/repo" @@ -185,6 +184,7 @@ func runWeb(*cli.Context) { if martini.Env == martini.Dev { m.Get("/template/**", dev.TemplatePreview) + dev.RegisterDebugRoutes(m) } reqTrueOwner := middleware.RequireTrueOwner() @@ -206,8 +206,6 @@ func runWeb(*cli.Context) { r.Post("/:org/settings/delete", org.DeletePost) }, reqSignIn) - debug.RegisterRoutes(m) - m.Group("/:username/:reponame", func(r martini.Router) { r.Get("/settings", repo.Setting) r.Post("/settings", bindIgnErr(auth.RepoSettingForm{}), repo.SettingPost) diff --git a/models/issue.go b/models/issue.go index 6d67a72b..baf710a5 100644 --- a/models/issue.go +++ b/models/issue.go @@ -276,6 +276,10 @@ func GetIssueUserPairs(rid, uid int64, isClosed bool) ([]*IssueUser, error) { // GetIssueUserPairsByRepoIds returns issue-user pairs by given repository IDs. func GetIssueUserPairsByRepoIds(rids []int64, isClosed bool, page int) ([]*IssueUser, error) { + if len(rids) == 0 { + return []*IssueUser{}, nil + } + buf := bytes.NewBufferString("") for _, rid := range rids { buf.WriteString("repo_id=") @@ -283,7 +287,6 @@ func GetIssueUserPairsByRepoIds(rids []int64, isClosed bool, page int) ([]*Issue buf.WriteString(" OR ") } cond := strings.TrimSuffix(buf.String(), " OR ") - ius := make([]*IssueUser, 0, 10) sess := x.Limit(20, (page-1)*20).Where("is_closed=?", isClosed) if len(cond) > 0 { diff --git a/routers/debug/debug.go b/routers/debug/debug.go deleted file mode 100644 index f61e7d2e..00000000 --- a/routers/debug/debug.go +++ /dev/null @@ -1,16 +0,0 @@ -// +build pprof - -package debug - -import ( - "net/http/pprof" - - "github.com/go-martini/martini" -) - -func RegisterRoutes(r martini.Router) { - r.Any("/debug/pprof/cmdline", pprof.Cmdline) - r.Any("/debug/pprof/profile", pprof.Profile) - r.Any("/debug/pprof/symbol", pprof.Symbol) - r.Any("/debug/pprof/**", pprof.Index) -} diff --git a/routers/debug/ignored.go b/routers/debug/ignored.go deleted file mode 100644 index 4ec49964..00000000 --- a/routers/debug/ignored.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build !pprof - -package debug - -import ( - "github.com/go-martini/martini" -) - -func RegisterRoutes(r martini.Router) { - // do nothing -} diff --git a/routers/dev/debug.go b/routers/dev/debug.go new file mode 100644 index 00000000..62022146 --- /dev/null +++ b/routers/dev/debug.go @@ -0,0 +1,18 @@ +// 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 dev + +import ( + "net/http/pprof" + + "github.com/go-martini/martini" +) + +func RegisterDebugRoutes(r martini.Router) { + r.Any("/debug/pprof/cmdline", pprof.Cmdline) + r.Any("/debug/pprof/profile", pprof.Profile) + r.Any("/debug/pprof/symbol", pprof.Symbol) + r.Any("/debug/pprof/**", pprof.Index) +} -- cgit v1.2.3