From 25fd495b2e790001e9c138205606ec4fa16bf129 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Sat, 12 Apr 2014 11:48:12 -0700 Subject: Add sqlite build tag This adds a sqlite build tag so that you don't have to have the sqlite import commented out in code and users can run: go build -tags sqlite if they want to have sqlite support enabled. It is disabled by default so nothing changes with the default go get or build commands. --- models/models_sqlite.go | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 models/models_sqlite.go (limited to 'models/models_sqlite.go') diff --git a/models/models_sqlite.go b/models/models_sqlite.go new file mode 100644 index 00000000..02c3f582 --- /dev/null +++ b/models/models_sqlite.go @@ -0,0 +1,11 @@ +// +build sqlite + +// 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 ( + _ "github.com/mattn/go-sqlite3" +) -- cgit v1.2.3 From 23bba7633bbd8ae8f9f41404352c327f9e8c9fdc Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 12 Apr 2014 16:24:09 -0400 Subject: Mirror fix on sqlite3 tag --- models/models.go | 6 +++++- models/models_sqlite.go | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'models/models_sqlite.go') diff --git a/models/models.go b/models/models.go index 010228ae..b8374a3d 100644 --- a/models/models.go +++ b/models/models.go @@ -26,7 +26,8 @@ var ( Type, Host, Name, User, Pwd, Path, SslMode string } - UseSQLite3 bool + EnableSQLite3 bool + UseSQLite3 bool ) func init() { @@ -56,6 +57,9 @@ func NewTestEngine(x *xorm.Engine) (err error) { x, err = xorm.NewEngine("postgres", fmt.Sprintf("user=%s password=%s dbname=%s sslmode=%s", DbCfg.User, DbCfg.Pwd, DbCfg.Name, DbCfg.SslMode)) case "sqlite3": + if !EnableSQLite3 { + return fmt.Errorf("Unknown database type: %s", DbCfg.Type) + } os.MkdirAll(path.Dir(DbCfg.Path), os.ModePerm) x, err = xorm.NewEngine("sqlite3", DbCfg.Path) default: diff --git a/models/models_sqlite.go b/models/models_sqlite.go index 02c3f582..1d80823f 100644 --- a/models/models_sqlite.go +++ b/models/models_sqlite.go @@ -1,11 +1,15 @@ -// +build sqlite - // 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. +// +build sqlite + package models import ( _ "github.com/mattn/go-sqlite3" ) + +func init() { + EnableSQLite3 = true +} -- cgit v1.2.3 From 9d983f27d69b72f42eeb833cb0f38e78e3819839 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 13 Apr 2014 03:14:43 -0400 Subject: go vet --- gogs.go | 4 ++-- models/models_sqlite.go | 4 ++-- models/update.go | 4 ++-- modules/base/tool.go | 1 - modules/mailer/mail.go | 2 +- modules/middleware/binding_test.go | 4 ++-- modules/oauth2/oauth2.go | 6 ------ 7 files changed, 9 insertions(+), 16 deletions(-) (limited to 'models/models_sqlite.go') diff --git a/gogs.go b/gogs.go index 1e614f49..7a7d3ac8 100644 --- a/gogs.go +++ b/gogs.go @@ -1,3 +1,5 @@ +// +build go1.2 + // 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. @@ -14,8 +16,6 @@ import ( "github.com/gogits/gogs/modules/base" ) -// +build go1.2 - // Test that go1.2 tag above is included in builds. main.go refers to this definition. const go12tag = true diff --git a/models/models_sqlite.go b/models/models_sqlite.go index 1d80823f..c77e5ae5 100644 --- a/models/models_sqlite.go +++ b/models/models_sqlite.go @@ -1,9 +1,9 @@ +// +build sqlite + // 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. -// +build sqlite - package models import ( diff --git a/models/update.go b/models/update.go index 53591fa4..ba0e9793 100644 --- a/models/update.go +++ b/models/update.go @@ -39,12 +39,12 @@ func Update(refName, oldCommitId, newCommitId, userName, repoName string, userId if isNew { l, err = newCommit.CommitsBefore() if err != nil { - qlog.Fatalf("Find CommitsBefore erro:", err) + qlog.Fatalf("Find CommitsBefore erro: %v", err) } } else { l, err = newCommit.CommitsBeforeUntil(oldCommitId) if err != nil { - qlog.Fatalf("Find CommitsBeforeUntil erro:", err) + qlog.Fatalf("Find CommitsBeforeUntil erro: %v", err) return } } diff --git a/modules/base/tool.go b/modules/base/tool.go index 0f06b3e0..082c0392 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -284,7 +284,6 @@ func TimeSince(then time.Time) string { default: return fmt.Sprintf("%d years %s", diff/Year, lbl) } - return then.String() } const ( diff --git a/modules/mailer/mail.go b/modules/mailer/mail.go index d2bf1310..834f4a89 100644 --- a/modules/mailer/mail.go +++ b/modules/mailer/mail.go @@ -152,7 +152,7 @@ func SendIssueMentionMail(user, owner *models.User, repo *models.Repository, iss } issueLink := fmt.Sprintf("%s%s/%s/issues/%d", base.AppUrl, owner.Name, repo.Name, issue.Index) - body := fmt.Sprintf(`%s mentioned you.`) + body := fmt.Sprintf(`%s mentioned you.`, user.Name) subject := fmt.Sprintf("[%s] %s", repo.Name, issue.Name) content := fmt.Sprintf("%s
-
View it on Gogs.", body, issueLink) msg := NewMailMessageFrom(tos, user.Name, subject, content) diff --git a/modules/middleware/binding_test.go b/modules/middleware/binding_test.go index 654cef29..2a74e1a6 100644 --- a/modules/middleware/binding_test.go +++ b/modules/middleware/binding_test.go @@ -121,7 +121,7 @@ func handle(test testCase, t *testing.T, index int, post BlogPost, errors Errors if test.ok && errors.Count() > 0 { t.Errorf("%+v should be OK (0 errors), but had errors: %+v", test, errors) } else if !test.ok && errors.Count() == 0 { - t.Errorf("%+v should have errors, but was OK (0 errors): %+v", test) + t.Errorf("%+v should have errors, but was OK (0 errors)", test) } } @@ -132,7 +132,7 @@ func handleEmpty(test emptyPayloadTestCase, t *testing.T, index int, section Blo if test.ok && errors.Count() > 0 { t.Errorf("%+v should be OK (0 errors), but had errors: %+v", test, errors) } else if !test.ok && errors.Count() == 0 { - t.Errorf("%+v should have errors, but was OK (0 errors): %+v", test) + t.Errorf("%+v should have errors, but was OK (0 errors)", test) } } diff --git a/modules/oauth2/oauth2.go b/modules/oauth2/oauth2.go index 05ae4606..dcb6d0a4 100644 --- a/modules/oauth2/oauth2.go +++ b/modules/oauth2/oauth2.go @@ -9,7 +9,6 @@ package oauth2 import ( "encoding/json" - "fmt" "net/http" "net/url" "strings" @@ -95,11 +94,6 @@ func (t *token) ExpiryTime() time.Time { return t.Expiry } -// Formats tokens into string. -func (t *token) String() string { - return fmt.Sprintf("tokens: %v", t) -} - // Returns a new Google OAuth 2.0 backend endpoint. func Google(opts *Options) martini.Handler { opts.AuthUrl = "https://accounts.google.com/o/oauth2/auth" -- cgit v1.2.3