mirror of
https://github.com/go-gitea/gitea
synced 2024-12-24 03:35:55 +01:00
Clean code
This commit is contained in:
parent
631deb2e7d
commit
828c89de99
@ -17,6 +17,7 @@ Please see [Wiki](https://github.com/gogits/gogs/wiki) for project design, devel
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
- Activity timeline
|
||||||
- SSH protocal support.
|
- SSH protocal support.
|
||||||
- Register/delete account.
|
- Register/delete account.
|
||||||
- Create/delete public repository.
|
- Create/delete public repository.
|
||||||
|
22
gogs.go
22
gogs.go
@ -7,7 +7,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
// "os/user"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
@ -27,14 +27,14 @@ func init() {
|
|||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkRunUser() bool {
|
// func checkRunUser() bool {
|
||||||
u, err := user.Current()
|
// u, err := user.Current()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
// TODO: log
|
// // TODO: log
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
return u.Username == base.Cfg.MustValue("", "RUN_USER")
|
// return u.Username == base.Cfg.MustValue("", "RUN_USER")
|
||||||
}
|
// }
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
/*if !checkRunUser() {
|
/*if !checkRunUser() {
|
||||||
@ -50,8 +50,6 @@ func main() {
|
|||||||
CmdWeb,
|
CmdWeb,
|
||||||
CmdServ,
|
CmdServ,
|
||||||
}
|
}
|
||||||
app.Flags = append(app.Flags, []cli.Flag{
|
app.Flags = append(app.Flags, []cli.Flag{}...)
|
||||||
cli.BoolFlag{"noterm", "disable color output"},
|
|
||||||
}...)
|
|
||||||
app.Run(os.Args)
|
app.Run(os.Args)
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ func GetRepositoryById(id int64) (repo *Repository, err error) {
|
|||||||
// GetRepositories returns the list of repositories of given user.
|
// GetRepositories returns the list of repositories of given user.
|
||||||
func GetRepositories(user *User) ([]Repository, error) {
|
func GetRepositories(user *User) ([]Repository, error) {
|
||||||
repos := make([]Repository, 0, 10)
|
repos := make([]Repository, 0, 10)
|
||||||
err := orm.Find(&repos, &Repository{OwnerId: user.Id})
|
err := orm.Desc("updated").Find(&repos, &Repository{OwnerId: user.Id})
|
||||||
return repos, err
|
return repos, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/codegangsta/martini"
|
"github.com/codegangsta/martini"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
@ -31,9 +33,7 @@ func RepoAssignment(redirect bool) martini.Handler {
|
|||||||
ctx.Render.Redirect("/")
|
ctx.Render.Redirect("/")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//data["ErrorMsg"] = err
|
ctx.Handle(200, "RepoAssignment", err)
|
||||||
//log.Error("repo.Single: %v", err)
|
|
||||||
//r.HTML(200, "base/error", data)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -45,9 +45,7 @@ func RepoAssignment(redirect bool) martini.Handler {
|
|||||||
ctx.Render.Redirect("/")
|
ctx.Render.Redirect("/")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//data["ErrorMsg"] = "invliad user account for single repository"
|
ctx.Handle(200, "RepoAssignment", errors.New("invliad user account for single repository"))
|
||||||
//log.Error("repo.Single: %v", err)
|
|
||||||
//r.HTML(200, "base/error", data)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,9 +58,7 @@ func RepoAssignment(redirect bool) martini.Handler {
|
|||||||
ctx.Render.Redirect("/")
|
ctx.Render.Redirect("/")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//data["ErrorMsg"] = err
|
ctx.Handle(200, "RepoAssignment", err)
|
||||||
//log.Error("repo.Single: %v", err)
|
|
||||||
//r.HTML(200, "base/error", data)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
serve.go
2
serve.go
@ -58,7 +58,7 @@ func runServ(*cli.Context) {
|
|||||||
|
|
||||||
cmd := os.Getenv("SSH_ORIGINAL_COMMAND")
|
cmd := os.Getenv("SSH_ORIGINAL_COMMAND")
|
||||||
if cmd == "" {
|
if cmd == "" {
|
||||||
println("Hi ", user.Name, "! You've successfully authenticated, but Gogs does not provide shell access.")
|
println("Hi", user.Name, "! You've successfully authenticated, but Gogs does not provide shell access.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
<div class="col-md-8 col-md-offset-2">
|
<div class="col-md-8 col-md-offset-2">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" name="initReadme">
|
<input type="checkbox" name="initReadme" {{if .initReadme}}checked{{end}}>
|
||||||
<strong>Initialize this repository with a README</strong>
|
<strong>Initialize this repository with a README</strong>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
2
web.go
2
web.go
@ -74,8 +74,6 @@ func runWeb(*cli.Context) {
|
|||||||
middleware.SignInRequire(false), middleware.RepoAssignment(true), repo.Single)
|
middleware.SignInRequire(false), middleware.RepoAssignment(true), repo.Single)
|
||||||
m.Get("/:username/:reponame", middleware.SignInRequire(false), middleware.RepoAssignment(true), repo.Single)
|
m.Get("/:username/:reponame", middleware.SignInRequire(false), middleware.RepoAssignment(true), repo.Single)
|
||||||
|
|
||||||
//m.Get("/:username/:reponame", repo.Repo)
|
|
||||||
|
|
||||||
listenAddr := fmt.Sprintf("%s:%s",
|
listenAddr := fmt.Sprintf("%s:%s",
|
||||||
base.Cfg.MustValue("server", "HTTP_ADDR"),
|
base.Cfg.MustValue("server", "HTTP_ADDR"),
|
||||||
base.Cfg.MustValue("server", "HTTP_PORT", "3000"))
|
base.Cfg.MustValue("server", "HTTP_PORT", "3000"))
|
||||||
|
Loading…
Reference in New Issue
Block a user