From 115a349131242201953a3f5693141679049355c6 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 8 Apr 2014 12:41:33 -0400 Subject: [PATCH] Fix #67 --- README.md | 2 +- README_ZH.md | 2 +- gogs.go | 2 +- models/repo.go | 12 ++++++++---- modules/base/conf.go | 1 + modules/base/template.go | 3 +++ routers/install.go | 1 + serve.go | 5 +---- templates/base/head.tmpl | 16 +++++++++++++--- 9 files changed, 30 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index fe15328b1b8..a4e8901c5db 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ More importantly, Gogs only needs one binary to setup your own project hosting o ## Features - Activity timeline -- SSH/HTTPS(Clone only) protocol support. +- SSH/HTTP(S) protocol support. - Register/delete/rename account. - Create/delete/watch/rename/transfer public repository. - Repository viewer. diff --git a/README_ZH.md b/README_ZH.md index 015ee0af995..2f801541027 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -23,7 +23,7 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依 ## 功能特性 - 活动时间线 -- SSH/HTTPS(仅限 Clone) 协议支持 +- SSH/HTTP(S) 协议支持 - 注册/删除/重命名用户 - 创建/删除/关注/重命名/转移公开仓库 - 仓库浏览器 diff --git a/gogs.go b/gogs.go index df268980f55..4616141e3d1 100644 --- a/gogs.go +++ b/gogs.go @@ -19,7 +19,7 @@ import ( // Test that go1.2 tag above is included in builds. main.go refers to this definition. const go12tag = true -const APP_VER = "0.2.2.0407 Alpha" +const APP_VER = "0.2.2.0408 Alpha" func init() { base.AppVer = APP_VER diff --git a/models/repo.go b/models/repo.go index bb5c36372ef..4f58f407faf 100644 --- a/models/repo.go +++ b/models/repo.go @@ -261,6 +261,13 @@ func createHookUpdate(hookPath, content string) error { return err } +// SetRepoEnvs sets environment variables for command update. +func SetRepoEnvs(userId int64, userName, repoName string) { + os.Setenv("userId", base.ToStr(userId)) + os.Setenv("userName", userName) + os.Setenv("repoName", repoName) +} + // InitRepository initializes README and .gitignore if needed. func initRepository(f string, user *User, repo *Repository, initReadme bool, repoLang, license string) error { repoPath := RepoPath(user.Name, repo.Name) @@ -333,10 +340,7 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep return nil } - // for update use - os.Setenv("userName", user.Name) - os.Setenv("userId", base.ToStr(user.Id)) - os.Setenv("repoName", repo.Name) + SetRepoEnvs(user.Id, user.Name, repo.Name) // Apply changes and commit. return initRepoCommit(tmpDir, user.NewGitSig()) diff --git a/modules/base/conf.go b/modules/base/conf.go index 69df49dc483..871595e4765 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -43,6 +43,7 @@ var ( AppName string AppLogo string AppUrl string + IsProdMode bool Domain string SecretKey string RunUser string diff --git a/modules/base/template.go b/modules/base/template.go index 6cd8ade6110..5a42107c451 100644 --- a/modules/base/template.go +++ b/modules/base/template.go @@ -56,6 +56,9 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{ "AppDomain": func() string { return Domain }, + "IsProdMode": func() bool { + return IsProdMode + }, "LoadTimes": func(startTime time.Time) string { return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms" }, diff --git a/routers/install.go b/routers/install.go index 1c4e6181d50..b9e8bb29078 100644 --- a/routers/install.go +++ b/routers/install.go @@ -27,6 +27,7 @@ func checkRunMode() { switch base.Cfg.MustValue("", "RUN_MODE") { case "prod": martini.Env = martini.Prod + base.IsProdMode = true case "test": martini.Env = martini.Test } diff --git a/serve.go b/serve.go index 7e00db47340..3843da617e0 100644 --- a/serve.go +++ b/serve.go @@ -177,10 +177,7 @@ func runServ(k *cli.Context) { qlog.Fatal("Unknown command") } - // for update use - os.Setenv("userName", user.Name) - os.Setenv("userId", strconv.Itoa(int(user.Id))) - os.Setenv("repoName", repoName) + models.SetRepoEnvs(user.Id, user.Name, repoName) gitcmd := exec.Command(verb, repoPath) gitcmd.Dir = base.RepoRootPath diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 7f56ed70806..2f88e918f31 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -11,14 +11,24 @@ + {{if IsProdMode}} + + + + + + {{else}} - - - + {{end}} + + + + + {{if .Title}}{{.Title}} - {{end}}{{AppName}}