From 0128036514ed40b2c878053e633762a8cffed74d Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 23 Nov 2015 22:32:07 -0500 Subject: [PATCH] #1681 some fixes for builtin SSH server on Windows --- README.md | 2 +- cmd/serve.go | 9 +++++++-- gogs.go | 2 +- routers/install.go | 1 + routers/repo/http.go | 6 +++--- templates/.VERSION | 2 +- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index dbad9dba3e..ba27503717 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra ![](public/img/gogs-large-resize.png) -##### Current version: 0.7.20 Beta +##### Current version: 0.7.21 Beta diff --git a/cmd/serve.go b/cmd/serve.go index b6ab9bb860..3d299e8875 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -65,7 +65,7 @@ func parseCmd(cmd string) (string, string) { } var ( - COMMANDS = map[string]models.AccessMode{ + allowedCommands = map[string]models.AccessMode{ "git-upload-pack": models.ACCESS_MODE_READ, "git-upload-archive": models.ACCESS_MODE_READ, "git-receive-pack": models.ACCESS_MODE_WRITE, @@ -163,7 +163,7 @@ func runServ(c *cli.Context) { fail("Internal error", "Failed to get repository: %v", err) } - requestedMode, has := COMMANDS[verb] + requestedMode, has := allowedCommands[verb] if !has { fail("Unknown git command", "Unknown git command %s", verb) } @@ -234,6 +234,11 @@ func runServ(c *cli.Context) { uuid := uuid.NewV4().String() os.Setenv("uuid", uuid) + // Special handle for Windows. + if setting.IsWindows { + verb = strings.Replace(verb, "-", " ", 1) + } + var gitcmd *exec.Cmd verbs := strings.Split(verb, " ") if len(verbs) == 2 { diff --git a/gogs.go b/gogs.go index 87f464153f..fc94514bd9 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.7.20.1121 Beta" +const APP_VER = "0.7.21.1123 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/routers/install.go b/routers/install.go index 5240b88e33..f3c51d06ac 100644 --- a/routers/install.go +++ b/routers/install.go @@ -222,6 +222,7 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) { } // Test repository root path. + 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) diff --git a/routers/repo/http.go b/routers/repo/http.go index 214cc9ba39..7bc5f1aff6 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -84,13 +84,13 @@ func HTTP(ctx *middleware.Context) { // check access if askAuth { - baHead := ctx.Req.Header.Get("Authorization") - if baHead == "" { + authHead := ctx.Req.Header.Get("Authorization") + if len(authHead) == 0 { authRequired(ctx) return } - auths := strings.Fields(baHead) + auths := strings.Fields(authHead) // currently check basic auth // TODO: support digit auth // FIXME: middlewares/context.go did basic auth check already, diff --git a/templates/.VERSION b/templates/.VERSION index 4bae731101..407198f7cc 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.7.20.1121 Beta \ No newline at end of file +0.7.21.1123 Beta \ No newline at end of file