Browse Source

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

pull/4240/head
Unknwon 8 years ago
parent
commit
e08161a302
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 6
      cmd/hook.go
  2. 2
      gogs.go
  3. 2
      templates/.VERSION
  4. 0
      vendor/github.com/gogits/minwinsvc/LICENSE
  5. 0
      vendor/github.com/gogits/minwinsvc/README.md
  6. 0
      vendor/github.com/gogits/minwinsvc/minwinsvc.go
  7. 0
      vendor/github.com/gogits/minwinsvc/svc_other.go
  8. 4
      vendor/github.com/gogits/minwinsvc/svc_windows.go
  9. 12
      vendor/vendor.json

6
cmd/hook.go

@ -117,7 +117,8 @@ func runHookPreReceive(c *cli.Context) error {
} }
// Check force push // 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 { if err != nil {
fail("Internal error", "Fail to detect force push: %v", err) fail("Internal error", "Fail to detect force push: %v", err)
} else if len(output) > 0 { } else if len(output) > 0 {
@ -131,6 +132,7 @@ func runHookPreReceive(c *cli.Context) error {
} }
hookCmd := exec.Command(customHooksPath) 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.Stdout = os.Stdout
hookCmd.Stdin = buf hookCmd.Stdin = buf
hookCmd.Stderr = os.Stderr hookCmd.Stderr = os.Stderr
@ -159,6 +161,7 @@ func runHookUpdate(c *cli.Context) error {
} }
hookCmd := exec.Command(customHooksPath, args...) 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.Stdout = os.Stdout
hookCmd.Stdin = os.Stdin hookCmd.Stdin = os.Stdin
hookCmd.Stderr = os.Stderr hookCmd.Stderr = os.Stderr
@ -231,6 +234,7 @@ func runHookPostReceive(c *cli.Context) error {
} }
hookCmd := exec.Command(customHooksPath) 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.Stdout = os.Stdout
hookCmd.Stdin = buf hookCmd.Stdin = buf
hookCmd.Stderr = os.Stderr hookCmd.Stderr = os.Stderr

2
gogs.go

@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
) )
const APP_VER = "0.10.2.0228" const APP_VER = "0.10.3.0228"
func init() { func init() {
setting.AppVer = APP_VER setting.AppVer = APP_VER

2
templates/.VERSION

@ -1 +1 @@
0.10.2.0228 0.10.3.0228

0
vendor/github.com/kardianos/minwinsvc/LICENSE → vendor/github.com/gogits/minwinsvc/LICENSE generated vendored

0
vendor/github.com/kardianos/minwinsvc/README.md → vendor/github.com/gogits/minwinsvc/README.md generated vendored

0
vendor/github.com/kardianos/minwinsvc/minwinsvc.go → vendor/github.com/gogits/minwinsvc/minwinsvc.go generated vendored

0
vendor/github.com/kardianos/minwinsvc/svc_other.go → vendor/github.com/gogits/minwinsvc/svc_other.go generated vendored

4
vendor/github.com/kardianos/minwinsvc/svc_windows.go → vendor/github.com/gogits/minwinsvc/svc_windows.go generated vendored

@ -23,7 +23,9 @@ func init() {
if err != nil { if err != nil {
panic(err) 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 return
} }
go func() { go func() {

12
vendor/vendor.json vendored

@ -176,6 +176,12 @@
"revision": "cd1abbd55d09b793672732a7a1dfdaa12a40dfd0", "revision": "cd1abbd55d09b793672732a7a1dfdaa12a40dfd0",
"revisionTime": "2016-11-20T02:51:54Z" "revisionTime": "2016-11-20T02:51:54Z"
}, },
{
"checksumSHA1": "cccKtXG5TiCiCT9JA85slbJokfw=",
"path": "github.com/gogits/minwinsvc",
"revision": "95be6356811a6fbd4c2981713236971a3ccbb33a",
"revisionTime": "2017-03-01T03:54:11Z"
},
{ {
"checksumSHA1": "MLO0PyrK2MUO6A7Z9PxWuu43C/A=", "checksumSHA1": "MLO0PyrK2MUO6A7Z9PxWuu43C/A=",
"path": "github.com/issue9/identicon", "path": "github.com/issue9/identicon",
@ -194,12 +200,6 @@
"revision": "8ddce2a84170772b95dd5d576c48d517b22cac63", "revision": "8ddce2a84170772b95dd5d576c48d517b22cac63",
"revisionTime": "2016-01-05T22:08:40Z" "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=", "checksumSHA1": "vfzz7zTL9TZLpFO7NC1H6/Du3+s=",
"path": "github.com/klauspost/compress/flate", "path": "github.com/klauspost/compress/flate",

Loading…
Cancel
Save