From 59d0e73c3507296b31c8e741b44afc7bfe1eb695 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 26 Apr 2014 22:34:48 -0600 Subject: [PATCH] Batch mirror fix --- .gopmfile | 1 + CONTRIBUTING.md | 2 ++ modules/base/conf.go | 8 +++--- modules/middleware/repo.go | 7 +++-- public/js/app.js | 4 +-- routers/install.go | 16 +++++++++++- routers/user/user.go | 8 +++--- templates/base/footer.tmpl | 5 +++- templates/install.tmpl | 13 +++++----- templates/repo/single_file.tmpl | 45 +++++++++++++++++---------------- tests/.travel.yml | 9 ------- tests/README.md | 13 ---------- tests/default_test.go | 17 ------------- 13 files changed, 68 insertions(+), 80 deletions(-) delete mode 100644 tests/.travel.yml delete mode 100644 tests/README.md delete mode 100644 tests/default_test.go diff --git a/.gopmfile b/.gopmfile index 296d02367e..c58f4299d4 100644 --- a/.gopmfile +++ b/.gopmfile @@ -19,6 +19,7 @@ github.com/lib/pq = github.com/nfnt/resize = github.com/qiniu/log = github.com/robfig/cron = +github.com/juju2013/goldap = [res] include = templates|public|conf diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cfc6c14f21..6cc88515f7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,6 +10,8 @@ Want to hack on Gogs? Awesome! Here are instructions to get you started. They ar ### Pull requests are always welcome +**ALL PULL REQUESTS MUST SEND TO `DEV` BRANCH** + We are always thrilled to receive pull requests, and do our best to process them as fast as possible. Not sure if that typo is worth a pull request? Do it! We will appreciate it. If your pull request is not accepted on the first try, don't be discouraged! If there's a problem with the implementation, hopefully you received feedback on what to improve. diff --git a/modules/base/conf.go b/modules/base/conf.go index 9a9adfdac6..17b55316a8 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -53,7 +53,6 @@ var ( Domain string SecretKey string RunUser string - LdapAuth bool RepoRootPath string ScriptType string @@ -93,6 +92,7 @@ var Service struct { NotifyMail bool ActiveCodeLives int ResetPwdCodeLives int + LdapAuth bool } func ExecDir() (string, error) { @@ -179,8 +179,8 @@ func newLogService() { } func newLdapService() { - LdapAuth = Cfg.MustBool("security", "LDAP_AUTH", false) - if !LdapAuth { + Service.LdapAuth = Cfg.MustBool("security", "LDAP_AUTH", false) + if !Service.LdapAuth { return } @@ -201,7 +201,7 @@ func newLdapService() { } if nbsrc == 0 { log.Warn("No valide LDAP found, LDAP Authentication NOT enabled") - LdapAuth = false + Service.LdapAuth = false return } diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index 34144fe3d8..2d2778cb00 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -26,11 +26,14 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler { var displayBare bool if len(args) >= 1 { - validBranch = args[0] + // Note: argument has wrong value in Go1.3 martini. + // validBranch = args[0] + validBranch = true } if len(args) >= 2 { - displayBare = args[1] + // displayBare = args[1] + displayBare = true } var ( diff --git a/public/js/app.js b/public/js/app.js index a5c79a3987..b7b5deb83b 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -470,10 +470,10 @@ function initInstall() { (function () { $('#install-database').on("change", function () { var val = $(this).val(); - if (val != "sqlite") { + if (val != "SQLite3") { $('.server-sql').show(); $('.sqlite-setting').addClass("hide"); - if (val == "pgsql") { + if (val == "PostgreSQL") { $('.pgsql-setting').removeClass("hide"); } else { $('.pgsql-setting').addClass("hide"); diff --git a/routers/install.go b/routers/install.go index 12182ad300..8ffa9b5d1a 100644 --- a/routers/install.go +++ b/routers/install.go @@ -65,6 +65,10 @@ func GlobalInit() { checkRunMode() } +func renderDbOption(ctx *middleware.Context) { + ctx.Data["DbOptions"] = []string{"MySQL", "PostgreSQL", "SQLite3"} +} + func Install(ctx *middleware.Context, form auth.InstallForm) { if base.InstallLock { ctx.Handle(404, "install.Install", errors.New("Installation is prohibited")) @@ -104,6 +108,13 @@ func Install(ctx *middleware.Context, form auth.InstallForm) { form.AppUrl = base.AppUrl } + renderDbOption(ctx) + curDbValue := "" + if models.EnableSQLite3 { + curDbValue = "SQLite3" // Default when enabled. + } + ctx.Data["CurDbValue"] = curDbValue + auth.AssignForm(form, ctx.Data) ctx.HTML(200, "install") } @@ -117,6 +128,9 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) { ctx.Data["Title"] = "Install" ctx.Data["PageIsInstall"] = true + renderDbOption(ctx) + ctx.Data["CurDbValue"] = form.Database + if ctx.HasError() { ctx.HTML(200, "install") return @@ -129,7 +143,7 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) { // Pass basic check, now test configuration. // Test database setting. - dbTypes := map[string]string{"mysql": "mysql", "pgsql": "postgres", "sqlite": "sqlite3"} + dbTypes := map[string]string{"MySQL": "mysql", "PostgreSQL": "postgres", "SQLite3": "sqlite3"} models.DbCfg.Type = dbTypes[form.Database] models.DbCfg.Host = form.Host models.DbCfg.User = form.User diff --git a/routers/user/user.go b/routers/user/user.go index 75314237dd..fe53896e41 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -91,12 +91,14 @@ func SignInPost(ctx *middleware.Context, form auth.LogInForm) { var user *models.User var err error - // try to login against LDAP if defined - if base.LdapAuth { + if base.Service.LdapAuth { user, err = models.LoginUserLdap(form.UserName, form.Password) + if err != nil { + log.Error("Fail to login through LDAP: %v", err) + } } // try local if not LDAP or it's failed - if (!base.LdapAuth) || (err != nil) { + if !base.Service.LdapAuth || err != nil { user, err = models.LoginUserPlain(form.UserName, form.Password) } if err != nil { diff --git a/templates/base/footer.tmpl b/templates/base/footer.tmpl index 6c2da63e5d..30f068913c 100644 --- a/templates/base/footer.tmpl +++ b/templates/base/footer.tmpl @@ -13,7 +13,10 @@
-

+ +
+

+
diff --git a/templates/install.tmpl b/templates/install.tmpl index 2ed7e569d1..8fe678e509 100644 --- a/templates/install.tmpl +++ b/templates/install.tmpl @@ -9,14 +9,15 @@
-
+
@@ -49,7 +50,7 @@
-
+