From e08161a3021236d8249a3b426967666b916f7d1e Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 28 Feb 2017 22:58:52 -0500 Subject: [PATCH] =?UTF-8?q?hook:=20fix=20can=E2=80=99t=20be=20executed=20w?= =?UTF-8?q?hile=20run=20as=20service=20on=20Windows=20(#4207)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/hook.go | 6 +++++- gogs.go | 2 +- templates/.VERSION | 2 +- .../{kardianos => gogits}/minwinsvc/LICENSE | 0 .../{kardianos => gogits}/minwinsvc/README.md | 0 .../{kardianos => gogits}/minwinsvc/minwinsvc.go | 0 .../{kardianos => gogits}/minwinsvc/svc_other.go | 0 .../{kardianos => gogits}/minwinsvc/svc_windows.go | 4 +++- vendor/vendor.json | 12 ++++++------ 9 files changed, 16 insertions(+), 10 deletions(-) rename vendor/github.com/{kardianos => gogits}/minwinsvc/LICENSE (100%) rename vendor/github.com/{kardianos => gogits}/minwinsvc/README.md (100%) rename vendor/github.com/{kardianos => gogits}/minwinsvc/minwinsvc.go (100%) rename vendor/github.com/{kardianos => gogits}/minwinsvc/svc_other.go (100%) rename vendor/github.com/{kardianos => gogits}/minwinsvc/svc_windows.go (84%) diff --git a/cmd/hook.go b/cmd/hook.go index fede86498..95db18f0f 100644 --- a/cmd/hook.go +++ b/cmd/hook.go @@ -117,7 +117,8 @@ func runHookPreReceive(c *cli.Context) error { } // Check force push - output, err := git.NewCommand("rev-list", oldCommitID, "^"+newCommitID).Run() + output, err := git.NewCommand("rev-list", oldCommitID, "^"+newCommitID). + RunInDir(models.RepoPath(os.Getenv(http.ENV_REPO_OWNER_NAME), os.Getenv(http.ENV_REPO_NAME))) if err != nil { fail("Internal error", "Fail to detect force push: %v", err) } else if len(output) > 0 { @@ -131,6 +132,7 @@ func runHookPreReceive(c *cli.Context) error { } hookCmd := exec.Command(customHooksPath) + hookCmd.Dir = models.RepoPath(os.Getenv(http.ENV_REPO_OWNER_NAME), os.Getenv(http.ENV_REPO_NAME)) hookCmd.Stdout = os.Stdout hookCmd.Stdin = buf hookCmd.Stderr = os.Stderr @@ -159,6 +161,7 @@ func runHookUpdate(c *cli.Context) error { } hookCmd := exec.Command(customHooksPath, args...) + hookCmd.Dir = models.RepoPath(os.Getenv(http.ENV_REPO_OWNER_NAME), os.Getenv(http.ENV_REPO_NAME)) hookCmd.Stdout = os.Stdout hookCmd.Stdin = os.Stdin hookCmd.Stderr = os.Stderr @@ -231,6 +234,7 @@ func runHookPostReceive(c *cli.Context) error { } hookCmd := exec.Command(customHooksPath) + hookCmd.Dir = models.RepoPath(os.Getenv(http.ENV_REPO_OWNER_NAME), os.Getenv(http.ENV_REPO_NAME)) hookCmd.Stdout = os.Stdout hookCmd.Stdin = buf hookCmd.Stderr = os.Stderr diff --git a/gogs.go b/gogs.go index 1882895f0..0d81503e1 100644 --- a/gogs.go +++ b/gogs.go @@ -16,7 +16,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.10.2.0228" +const APP_VER = "0.10.3.0228" func init() { setting.AppVer = APP_VER diff --git a/templates/.VERSION b/templates/.VERSION index 3762da787..59bae7e51 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.10.2.0228 \ No newline at end of file +0.10.3.0228 \ No newline at end of file diff --git a/vendor/github.com/kardianos/minwinsvc/LICENSE b/vendor/github.com/gogits/minwinsvc/LICENSE similarity index 100% rename from vendor/github.com/kardianos/minwinsvc/LICENSE rename to vendor/github.com/gogits/minwinsvc/LICENSE diff --git a/vendor/github.com/kardianos/minwinsvc/README.md b/vendor/github.com/gogits/minwinsvc/README.md similarity index 100% rename from vendor/github.com/kardianos/minwinsvc/README.md rename to vendor/github.com/gogits/minwinsvc/README.md diff --git a/vendor/github.com/kardianos/minwinsvc/minwinsvc.go b/vendor/github.com/gogits/minwinsvc/minwinsvc.go similarity index 100% rename from vendor/github.com/kardianos/minwinsvc/minwinsvc.go rename to vendor/github.com/gogits/minwinsvc/minwinsvc.go diff --git a/vendor/github.com/kardianos/minwinsvc/svc_other.go b/vendor/github.com/gogits/minwinsvc/svc_other.go similarity index 100% rename from vendor/github.com/kardianos/minwinsvc/svc_other.go rename to vendor/github.com/gogits/minwinsvc/svc_other.go diff --git a/vendor/github.com/kardianos/minwinsvc/svc_windows.go b/vendor/github.com/gogits/minwinsvc/svc_windows.go similarity index 84% rename from vendor/github.com/kardianos/minwinsvc/svc_windows.go rename to vendor/github.com/gogits/minwinsvc/svc_windows.go index 91e2b6a4d..e79755fa0 100644 --- a/vendor/github.com/kardianos/minwinsvc/svc_windows.go +++ b/vendor/github.com/gogits/minwinsvc/svc_windows.go @@ -23,7 +23,9 @@ func init() { if err != nil { panic(err) } - if interactive { + // While run as Windows service, it is not an interactive session, + // but we don't want hook execute to be treated as service, e.g. gogs.exe hook pre-receive. + if interactive || len(os.Getenv("SSH_ORIGINAL_COMMAND")) > 0 { return } go func() { diff --git a/vendor/vendor.json b/vendor/vendor.json index 32b0465a1..0e4cf311d 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -176,6 +176,12 @@ "revision": "cd1abbd55d09b793672732a7a1dfdaa12a40dfd0", "revisionTime": "2016-11-20T02:51:54Z" }, + { + "checksumSHA1": "cccKtXG5TiCiCT9JA85slbJokfw=", + "path": "github.com/gogits/minwinsvc", + "revision": "95be6356811a6fbd4c2981713236971a3ccbb33a", + "revisionTime": "2017-03-01T03:54:11Z" + }, { "checksumSHA1": "MLO0PyrK2MUO6A7Z9PxWuu43C/A=", "path": "github.com/issue9/identicon", @@ -194,12 +200,6 @@ "revision": "8ddce2a84170772b95dd5d576c48d517b22cac63", "revisionTime": "2016-01-05T22:08:40Z" }, - { - "checksumSHA1": "/dBJ2h8Jo359deiC5GQ8ZYzX8M8=", - "path": "github.com/kardianos/minwinsvc", - "revision": "cad6b2b879b0970e4245a20ebf1a81a756e2bb70", - "revisionTime": "2015-11-22T16:33:09Z" - }, { "checksumSHA1": "vfzz7zTL9TZLpFO7NC1H6/Du3+s=", "path": "github.com/klauspost/compress/flate",