summaryrefslogtreecommitdiffstats
path: root/routers/private/hook.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-08-14 10:25:05 +0100
committerLauris BH <lauris@nix.lv>2019-08-14 12:25:05 +0300
commitdef84840dbce6d725618e1aeab4ca1f665600087 (patch)
treeb8e73be1d7a182103c0ebf6f02392295d31aa737 /routers/private/hook.go
parent7eed11e5e9855324dd328a99133bf1f668076f80 (diff)
downloadgitea-def84840dbce6d725618e1aeab4ca1f665600087.tar.gz
gitea-def84840dbce6d725618e1aeab4ca1f665600087.zip
Attempt to fix hook problem (#7854)
Diffstat (limited to 'routers/private/hook.go')
-rw-r--r--routers/private/hook.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/routers/private/hook.go b/routers/private/hook.go
index 1071c57bc0..ee77a00321 100644
--- a/routers/private/hook.go
+++ b/routers/private/hook.go
@@ -31,6 +31,7 @@ func HookPreReceive(ctx *macaron.Context) {
userID := ctx.QueryInt64("userID")
gitObjectDirectory := ctx.QueryTrim("gitObjectDirectory")
gitAlternativeObjectDirectories := ctx.QueryTrim("gitAlternativeObjectDirectories")
+ gitQuarantinePath := ctx.QueryTrim("gitQuarantinePath")
prID := ctx.QueryInt64("prID")
branchName := strings.TrimPrefix(refFullName, git.BranchPrefix)
@@ -63,11 +64,19 @@ func HookPreReceive(ctx *macaron.Context) {
// detect force push
if git.EmptySHA != oldCommitID {
- env := append(os.Environ(),
- private.GitAlternativeObjectDirectories+"="+gitAlternativeObjectDirectories,
- private.GitObjectDirectory+"="+gitObjectDirectory,
- private.GitQuarantinePath+"="+gitObjectDirectory,
- )
+ env := os.Environ()
+ if gitAlternativeObjectDirectories != "" {
+ env = append(env,
+ private.GitAlternativeObjectDirectories+"="+gitAlternativeObjectDirectories)
+ }
+ if gitObjectDirectory != "" {
+ env = append(env,
+ private.GitObjectDirectory+"="+gitObjectDirectory)
+ }
+ if gitQuarantinePath != "" {
+ env = append(env,
+ private.GitQuarantinePath+"="+gitQuarantinePath)
+ }
output, err := git.NewCommand("rev-list", "--max-count=1", oldCommitID, "^"+newCommitID).RunInDirWithEnv(repo.RepoPath(), env)
if err != nil {