mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Clean code
This commit is contained in:
		| @@ -17,6 +17,7 @@ Please see [Wiki](https://github.com/gogits/gogs/wiki) for project design, devel | ||||
|  | ||||
| ## Features | ||||
|  | ||||
| - Activity timeline | ||||
| - SSH protocal support. | ||||
| - Register/delete account. | ||||
| - Create/delete public repository. | ||||
|   | ||||
							
								
								
									
										22
									
								
								gogs.go
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								gogs.go
									
									
									
									
									
								
							| @@ -7,7 +7,7 @@ package main | ||||
|  | ||||
| import ( | ||||
| 	"os" | ||||
| 	"os/user" | ||||
| 	// "os/user" | ||||
| 	"runtime" | ||||
|  | ||||
| 	"github.com/codegangsta/cli" | ||||
| @@ -27,14 +27,14 @@ func init() { | ||||
| 	runtime.GOMAXPROCS(runtime.NumCPU()) | ||||
| } | ||||
|  | ||||
| func checkRunUser() bool { | ||||
| 	u, err := user.Current() | ||||
| 	if err != nil { | ||||
| 		// TODO: log | ||||
| 		return false | ||||
| 	} | ||||
| 	return u.Username == base.Cfg.MustValue("", "RUN_USER") | ||||
| } | ||||
| // func checkRunUser() bool { | ||||
| // 	u, err := user.Current() | ||||
| // 	if err != nil { | ||||
| // 		// TODO: log | ||||
| // 		return false | ||||
| // 	} | ||||
| // 	return u.Username == base.Cfg.MustValue("", "RUN_USER") | ||||
| // } | ||||
|  | ||||
| func main() { | ||||
| 	/*if !checkRunUser() { | ||||
| @@ -50,8 +50,6 @@ func main() { | ||||
| 		CmdWeb, | ||||
| 		CmdServ, | ||||
| 	} | ||||
| 	app.Flags = append(app.Flags, []cli.Flag{ | ||||
| 		cli.BoolFlag{"noterm", "disable color output"}, | ||||
| 	}...) | ||||
| 	app.Flags = append(app.Flags, []cli.Flag{}...) | ||||
| 	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. | ||||
| func GetRepositories(user *User) ([]Repository, error) { | ||||
| 	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 | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -5,6 +5,8 @@ | ||||
| package middleware | ||||
|  | ||||
| import ( | ||||
| 	"errors" | ||||
|  | ||||
| 	"github.com/codegangsta/martini" | ||||
|  | ||||
| 	"github.com/gogits/gogs/models" | ||||
| @@ -31,9 +33,7 @@ func RepoAssignment(redirect bool) martini.Handler { | ||||
| 					ctx.Render.Redirect("/") | ||||
| 					return | ||||
| 				} | ||||
| 				//data["ErrorMsg"] = err | ||||
| 				//log.Error("repo.Single: %v", err) | ||||
| 				//r.HTML(200, "base/error", data) | ||||
| 				ctx.Handle(200, "RepoAssignment", err) | ||||
| 				return | ||||
| 			} | ||||
| 		} else { | ||||
| @@ -45,9 +45,7 @@ func RepoAssignment(redirect bool) martini.Handler { | ||||
| 				ctx.Render.Redirect("/") | ||||
| 				return | ||||
| 			} | ||||
| 			//data["ErrorMsg"] = "invliad user account for single repository" | ||||
| 			//log.Error("repo.Single: %v", err) | ||||
| 			//r.HTML(200, "base/error", data) | ||||
| 			ctx.Handle(200, "RepoAssignment", errors.New("invliad user account for single repository")) | ||||
| 			return | ||||
| 		} | ||||
|  | ||||
| @@ -60,9 +58,7 @@ func RepoAssignment(redirect bool) martini.Handler { | ||||
| 				ctx.Render.Redirect("/") | ||||
| 				return | ||||
| 			} | ||||
| 			//data["ErrorMsg"] = err | ||||
| 			//log.Error("repo.Single: %v", err) | ||||
| 			//r.HTML(200, "base/error", data) | ||||
| 			ctx.Handle(200, "RepoAssignment", err) | ||||
| 			return | ||||
| 		} | ||||
|  | ||||
|   | ||||
							
								
								
									
										2
									
								
								serve.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								serve.go
									
									
									
									
									
								
							| @@ -58,7 +58,7 @@ func runServ(*cli.Context) { | ||||
|  | ||||
| 	cmd := os.Getenv("SSH_ORIGINAL_COMMAND") | ||||
| 	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 | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -59,7 +59,7 @@ | ||||
|             <div class="col-md-8 col-md-offset-2"> | ||||
|                 <div class="checkbox"> | ||||
|                     <label> | ||||
|                         <input type="checkbox" name="initReadme"> | ||||
|                         <input type="checkbox" name="initReadme" {{if .initReadme}}checked{{end}}> | ||||
|                         <strong>Initialize this repository with a README</strong> | ||||
|                     </label> | ||||
|                 </div> | ||||
|   | ||||
							
								
								
									
										2
									
								
								web.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								web.go
									
									
									
									
									
								
							| @@ -74,8 +74,6 @@ func runWeb(*cli.Context) { | ||||
| 		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", | ||||
| 		base.Cfg.MustValue("server", "HTTP_ADDR"), | ||||
| 		base.Cfg.MustValue("server", "HTTP_PORT", "3000")) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user