Always write proc-receive hook for all git versions (#29287)

(cherry picked from commit 7f45dfb030f30a3ada58e636e3b8bfde391224bd)
This commit is contained in:
wxiaoguang 2024-02-21 15:01:48 +08:00 committed by Earl Warren
parent d3a642a7e0
commit 2c8f112c1c
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -9,7 +9,6 @@ import (
"path/filepath" "path/filepath"
"runtime" "runtime"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/util"
) )
@ -94,7 +93,7 @@ done
`, setting.ScriptType, util.ShellEscape(setting.AppPath), util.ShellEscape(setting.CustomConf)), `, setting.ScriptType, util.ShellEscape(setting.AppPath), util.ShellEscape(setting.CustomConf)),
} }
if git.SupportProcReceive { // although only new git (>=2.29) supports proc-receive, it's still good to create its hook, in case the user upgrades git
hookNames = append(hookNames, "proc-receive") hookNames = append(hookNames, "proc-receive")
hookTpls = append(hookTpls, hookTpls = append(hookTpls,
fmt.Sprintf(`#!/usr/bin/env %s fmt.Sprintf(`#!/usr/bin/env %s
@ -102,7 +101,6 @@ done
%s hook --config=%s proc-receive %s hook --config=%s proc-receive
`, setting.ScriptType, util.ShellEscape(setting.AppPath), util.ShellEscape(setting.CustomConf))) `, setting.ScriptType, util.ShellEscape(setting.AppPath), util.ShellEscape(setting.CustomConf)))
giteaHookTpls = append(giteaHookTpls, "") giteaHookTpls = append(giteaHookTpls, "")
}
return hookNames, hookTpls, giteaHookTpls return hookNames, hookTpls, giteaHookTpls
} }