diff --git a/conf/app.ini b/conf/app.ini index 25fd41091..e7174e225 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -16,6 +16,8 @@ LICENSES = Apache v2 License|GPL v2|MIT License|Affero GPL|Artistic License 2.0| PROTOCOL = http DOMAIN = localhost ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/ +; Disable CDN even in "prod" mode +OFFLINE_MODE = false HTTP_ADDR = HTTP_PORT = 3000 ; Generate steps: diff --git a/gogs.go b/gogs.go index caa8cf63d..1a8b4d131 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.3.0.0426 Alpha" +const APP_VER = "0.3.0.0427 Alpha" func init() { base.AppVer = APP_VER diff --git a/models/repo.go b/models/repo.go index 245717437..5f66bca86 100644 --- a/models/repo.go +++ b/models/repo.go @@ -159,9 +159,7 @@ func MirrorUpdate() { repoPath := filepath.Join(base.RepoRootPath, m.RepoName+".git") _, stderr, err := com.ExecCmdDir(repoPath, "git", "remote", "update") if err != nil { - return err - } else if strings.Contains(stderr, "fatal:") { - return errors.New(stderr) + return errors.New("git remote update: " + stderr) } else if err = git.UnpackRefs(repoPath); err != nil { return err } @@ -177,9 +175,7 @@ func MirrorUpdate() { func MirrorRepository(repoId int64, userName, repoName, repoPath, url string) error { _, stderr, err := com.ExecCmd("git", "clone", "--mirror", url, repoPath) if err != nil { - return err - } else if strings.Contains(stderr, "fatal:") { - return errors.New(stderr) + return errors.New("git clone --mirror: " + stderr) } if _, err = orm.InsertOne(&Mirror{ @@ -219,23 +215,17 @@ func MigrateRepository(user *User, name, desc string, private, mirror bool, url // Clone from local repository. _, stderr, err := com.ExecCmd("git", "clone", repoPath, tmpDir) if err != nil { - return repo, err - } else if strings.Contains(stderr, "fatal:") { return repo, errors.New("git clone: " + stderr) } // Pull data from source. _, stderr, err = com.ExecCmdDir(tmpDir, "git", "pull", url) if err != nil { - return repo, err - } else if strings.Contains(stderr, "fatal:") { return repo, errors.New("git pull: " + stderr) } // Push data to local repository. if _, stderr, err = com.ExecCmdDir(tmpDir, "git", "push", "origin", "master"); err != nil { - return repo, err - } else if strings.Contains(stderr, "fatal:") { return repo, errors.New("git push: " + stderr) } @@ -429,8 +419,6 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep _, stderr, err := com.ExecCmd("git", "clone", repoPath, tmpDir) if err != nil { - return err - } else if strings.Contains(stderr, "fatal:") { return errors.New("git clone: " + stderr) } diff --git a/models/update.go b/models/update.go index 2f59547b7..648c45f16 100644 --- a/models/update.go +++ b/models/update.go @@ -1,3 +1,7 @@ +// 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 models import ( @@ -5,9 +9,11 @@ import ( "os/exec" "strings" + qlog "github.com/qiniu/log" + "github.com/gogits/git" + "github.com/gogits/gogs/modules/base" - qlog "github.com/qiniu/log" ) func Update(refName, oldCommitId, newCommitId, userName, repoName string, userId int64) { diff --git a/modules/base/conf.go b/modules/base/conf.go index 17b55316a..cfc85ff51 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -45,14 +45,15 @@ type Oauther struct { } var ( - AppVer string - AppName string - AppLogo string - AppUrl string - IsProdMode bool - Domain string - SecretKey string - RunUser string + AppVer string + AppName string + AppLogo string + AppUrl string + OfflineMode bool + ProdMode bool + Domain string + SecretKey string + RunUser string RepoRootPath string ScriptType string @@ -325,6 +326,7 @@ func NewConfigContext() { AppLogo = Cfg.MustValue("", "APP_LOGO", "img/favicon.png") AppUrl = Cfg.MustValue("server", "ROOT_URL") Domain = Cfg.MustValue("server", "DOMAIN") + OfflineMode = Cfg.MustBool("server", "OFFLINE_MODE", false) SecretKey = Cfg.MustValue("security", "SECRET_KEY") InstallLock = Cfg.MustBool("security", "INSTALL_LOCK", false) diff --git a/modules/base/template.go b/modules/base/template.go index 79aeeb9d7..dd98df75b 100644 --- a/modules/base/template.go +++ b/modules/base/template.go @@ -56,8 +56,8 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{ "AppDomain": func() string { return Domain }, - "IsProdMode": func() bool { - return IsProdMode + "CdnMode": func() bool { + return ProdMode && !OfflineMode }, "LoadTimes": func(startTime time.Time) string { return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms" @@ -124,11 +124,11 @@ func ActionIcon(opType int) string { const ( TPL_CREATE_REPO = `%s created repository %s` TPL_COMMIT_REPO = `%s pushed to %s at %s%s` - TPL_COMMIT_REPO_LI = `
%s
to %s`
- TPL_PUSH_TAG = `%s pushed tag %s at %s`
+ TPL_PUSH_TAG = `%s pushed tag %s at %s`
)
type PushCommit struct {
@@ -165,7 +165,7 @@ func ActionDesc(act Actioner) string {
buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, AvatarLink(commit.AuthorEmail), repoLink, commit.Sha1, commit.Sha1[:7], commit.Message) + "\n")
}
if push.Len > 3 {
- buf.WriteString(fmt.Sprintf(``, actUserName, repoName, branch, push.Len))
+ buf.WriteString(fmt.Sprintf(``, actUserName, repoName, branch, push.Len))
}
return fmt.Sprintf(TPL_COMMIT_REPO, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink,
buf.String())
diff --git a/routers/admin/admin.go b/routers/admin/admin.go
index d0f737e64..fddd83018 100644
--- a/routers/admin/admin.go
+++ b/routers/admin/admin.go
@@ -139,9 +139,11 @@ func Config(ctx *middleware.Context) {
ctx.Data["AppUrl"] = base.AppUrl
ctx.Data["Domain"] = base.Domain
+ ctx.Data["OfflineMode"] = base.OfflineMode
ctx.Data["RunUser"] = base.RunUser
ctx.Data["RunMode"] = strings.Title(martini.Env)
ctx.Data["RepoRootPath"] = base.RepoRootPath
+ ctx.Data["ScriptType"] = base.ScriptType
ctx.Data["Service"] = base.Service
diff --git a/routers/install.go b/routers/install.go
index 8ffa9b5d1..38bf896f4 100644
--- a/routers/install.go
+++ b/routers/install.go
@@ -30,7 +30,7 @@ func checkRunMode() {
switch base.Cfg.MustValue("", "RUN_MODE") {
case "prod":
martini.Env = martini.Prod
- base.IsProdMode = true
+ base.ProdMode = true
case "test":
martini.Env = martini.Test
}
diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl
index d25d40275..b2b25e90f 100644
--- a/templates/admin/config.tmpl
+++ b/templates/admin/config.tmpl
@@ -18,6 +18,8 @@