hook: fix can’t be executed while run as service on Windows (#4207)

master
Unknwon 2017-02-28 22:58:52 -05:00
parent 341eafcf04
commit e08161a302
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
9 changed files with 16 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -1 +1 @@
0.10.2.0228
0.10.3.0228

View File

@ -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() {

12
vendor/vendor.json vendored
View File

@ -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",