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

Backport #29287

(cherry picked from commit 9379352db638aa99ee9f4a7d2755966f3d866541)
This commit is contained in:
wxiaoguang 2024-02-21 19:08:34 +08:00 committed by Earl Warren
parent c49dd9de9b
commit a1fb6a2346
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -9,7 +9,6 @@ import (
"path/filepath"
"runtime"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
)
@ -94,15 +93,14 @@ done
`, setting.ScriptType, util.ShellEscape(setting.AppPath), util.ShellEscape(setting.CustomConf)),
}
if git.SupportProcReceive {
hookNames = append(hookNames, "proc-receive")
hookTpls = append(hookTpls,
fmt.Sprintf(`#!/usr/bin/env %s
// 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")
hookTpls = append(hookTpls,
fmt.Sprintf(`#!/usr/bin/env %s
# AUTO GENERATED BY GITEA, DO NOT MODIFY
%s hook --config=%s proc-receive
`, setting.ScriptType, util.ShellEscape(setting.AppPath), util.ShellEscape(setting.CustomConf)))
giteaHookTpls = append(giteaHookTpls, "")
}
giteaHookTpls = append(giteaHookTpls, "")
return hookNames, hookTpls, giteaHookTpls
}