-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
golint fixed for parts of routers root, dev, user and org dirs #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bf7187e
golint fixed for parts of routers root, dev and org dirs
lunny ad03524
add user/auth.go golint fixed
lunny 0169728
Merge branch 'lunny/golint_routers_2' into lunny/golint_routers
lunny e39731b
rename unnecessary exported to unexported and user dir golint fixed
lunny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,8 @@ import ( | |
) | ||
|
||
const ( | ||
INSTALL base.TplName = "install" | ||
// tplInstall template for installation page | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need for a comment here since it isn't exported 🙂 |
||
tplInstall base.TplName = "install" | ||
) | ||
|
||
func checkRunMode() { | ||
|
@@ -49,6 +50,7 @@ func checkRunMode() { | |
log.Info("Run Mode: %s", strings.Title(macaron.Env)) | ||
} | ||
|
||
// NewServices init new services | ||
func NewServices() { | ||
setting.NewServices() | ||
mailer.NewContext() | ||
|
@@ -97,6 +99,7 @@ func GlobalInit() { | |
} | ||
} | ||
|
||
// InstallInit prepare for rendering installation page | ||
func InstallInit(ctx *context.Context) { | ||
if setting.InstallLock { | ||
ctx.Handle(404, "Install", errors.New("Installation is prohibited")) | ||
|
@@ -116,6 +119,7 @@ func InstallInit(ctx *context.Context) { | |
ctx.Data["DbOptions"] = dbOpts | ||
} | ||
|
||
// Install render installation page | ||
func Install(ctx *context.Context) { | ||
form := auth.InstallForm{} | ||
|
||
|
@@ -175,9 +179,10 @@ func Install(ctx *context.Context) { | |
form.RequireSignInView = setting.Service.RequireSignInView | ||
|
||
auth.AssignForm(form, ctx.Data) | ||
ctx.HTML(200, INSTALL) | ||
ctx.HTML(200, tplInstall) | ||
} | ||
|
||
// InstallPost response for submit install items | ||
func InstallPost(ctx *context.Context, form auth.InstallForm) { | ||
ctx.Data["CurDbOption"] = form.DbType | ||
|
||
|
@@ -191,12 +196,12 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) { | |
ctx.Data["Err_Admin"] = true | ||
} | ||
|
||
ctx.HTML(200, INSTALL) | ||
ctx.HTML(200, tplInstall) | ||
return | ||
} | ||
|
||
if _, err := exec.LookPath("git"); err != nil { | ||
ctx.RenderWithErr(ctx.Tr("install.test_git_failed", err), INSTALL, &form) | ||
ctx.RenderWithErr(ctx.Tr("install.test_git_failed", err), tplInstall, &form) | ||
return | ||
} | ||
|
||
|
@@ -214,12 +219,12 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) { | |
if (models.DbCfg.Type == "sqlite3" || models.DbCfg.Type == "tidb") && | ||
len(models.DbCfg.Path) == 0 { | ||
ctx.Data["Err_DbPath"] = true | ||
ctx.RenderWithErr(ctx.Tr("install.err_empty_db_path"), INSTALL, &form) | ||
ctx.RenderWithErr(ctx.Tr("install.err_empty_db_path"), tplInstall, &form) | ||
return | ||
} else if models.DbCfg.Type == "tidb" && | ||
strings.ContainsAny(path.Base(models.DbCfg.Path), ".-") { | ||
ctx.Data["Err_DbPath"] = true | ||
ctx.RenderWithErr(ctx.Tr("install.err_invalid_tidb_name"), INSTALL, &form) | ||
ctx.RenderWithErr(ctx.Tr("install.err_invalid_tidb_name"), tplInstall, &form) | ||
return | ||
} | ||
|
||
|
@@ -228,10 +233,10 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) { | |
if err := models.NewTestEngine(x); err != nil { | ||
if strings.Contains(err.Error(), `Unknown database type: sqlite3`) { | ||
ctx.Data["Err_DbType"] = true | ||
ctx.RenderWithErr(ctx.Tr("install.sqlite3_not_available", "https://gogs.io/docs/installation/install_from_binary.html"), INSTALL, &form) | ||
ctx.RenderWithErr(ctx.Tr("install.sqlite3_not_available", "https://gogs.io/docs/installation/install_from_binary.html"), tplInstall, &form) | ||
} else { | ||
ctx.Data["Err_DbSetting"] = true | ||
ctx.RenderWithErr(ctx.Tr("install.invalid_db_setting", err), INSTALL, &form) | ||
ctx.RenderWithErr(ctx.Tr("install.invalid_db_setting", err), tplInstall, &form) | ||
} | ||
return | ||
} | ||
|
@@ -240,44 +245,44 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) { | |
form.RepoRootPath = strings.Replace(form.RepoRootPath, "\\", "/", -1) | ||
if err := os.MkdirAll(form.RepoRootPath, os.ModePerm); err != nil { | ||
ctx.Data["Err_RepoRootPath"] = true | ||
ctx.RenderWithErr(ctx.Tr("install.invalid_repo_path", err), INSTALL, &form) | ||
ctx.RenderWithErr(ctx.Tr("install.invalid_repo_path", err), tplInstall, &form) | ||
return | ||
} | ||
|
||
// Test log root path. | ||
form.LogRootPath = strings.Replace(form.LogRootPath, "\\", "/", -1) | ||
if err := os.MkdirAll(form.LogRootPath, os.ModePerm); err != nil { | ||
ctx.Data["Err_LogRootPath"] = true | ||
ctx.RenderWithErr(ctx.Tr("install.invalid_log_root_path", err), INSTALL, &form) | ||
ctx.RenderWithErr(ctx.Tr("install.invalid_log_root_path", err), tplInstall, &form) | ||
return | ||
} | ||
|
||
currentUser, match := setting.IsRunUserMatchCurrentUser(form.RunUser) | ||
if !match { | ||
ctx.Data["Err_RunUser"] = true | ||
ctx.RenderWithErr(ctx.Tr("install.run_user_not_match", form.RunUser, currentUser), INSTALL, &form) | ||
ctx.RenderWithErr(ctx.Tr("install.run_user_not_match", form.RunUser, currentUser), tplInstall, &form) | ||
return | ||
} | ||
|
||
// Check logic loophole between disable self-registration and no admin account. | ||
if form.DisableRegistration && len(form.AdminName) == 0 { | ||
ctx.Data["Err_Services"] = true | ||
ctx.Data["Err_Admin"] = true | ||
ctx.RenderWithErr(ctx.Tr("install.no_admin_and_disable_registration"), INSTALL, form) | ||
ctx.RenderWithErr(ctx.Tr("install.no_admin_and_disable_registration"), tplInstall, form) | ||
return | ||
} | ||
|
||
// Check admin password. | ||
if len(form.AdminName) > 0 && len(form.AdminPasswd) == 0 { | ||
ctx.Data["Err_Admin"] = true | ||
ctx.Data["Err_AdminPasswd"] = true | ||
ctx.RenderWithErr(ctx.Tr("install.err_empty_admin_password"), INSTALL, form) | ||
ctx.RenderWithErr(ctx.Tr("install.err_empty_admin_password"), tplInstall, form) | ||
return | ||
} | ||
if form.AdminPasswd != form.AdminConfirmPasswd { | ||
ctx.Data["Err_Admin"] = true | ||
ctx.Data["Err_AdminPasswd"] = true | ||
ctx.RenderWithErr(ctx.Tr("form.password_not_match"), INSTALL, form) | ||
ctx.RenderWithErr(ctx.Tr("form.password_not_match"), tplInstall, form) | ||
return | ||
} | ||
|
||
|
@@ -347,12 +352,12 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) { | |
|
||
err := os.MkdirAll(filepath.Dir(setting.CustomConf), os.ModePerm) | ||
if err != nil { | ||
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form) | ||
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), tplInstall, &form) | ||
return | ||
} | ||
|
||
if err := cfg.SaveTo(setting.CustomConf); err != nil { | ||
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form) | ||
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), tplInstall, &form) | ||
return | ||
} | ||
|
||
|
@@ -372,7 +377,7 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) { | |
setting.InstallLock = false | ||
ctx.Data["Err_AdminName"] = true | ||
ctx.Data["Err_AdminEmail"] = true | ||
ctx.RenderWithErr(ctx.Tr("install.invalid_admin_setting", err), INSTALL, &form) | ||
ctx.RenderWithErr(ctx.Tr("install.invalid_admin_setting", err), tplInstall, &form) | ||
return | ||
} | ||
log.Info("Admin account already exist") | ||
|
@@ -381,11 +386,11 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) { | |
|
||
// Auto-login for admin | ||
if err := ctx.Session.Set("uid", u.ID); err != nil { | ||
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form) | ||
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), tplInstall, &form) | ||
return | ||
} | ||
if err := ctx.Session.Set("uname", u.Name); err != nil { | ||
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form) | ||
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), tplInstall, &form) | ||
return | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could just be
RenderUserSearch page
:)