@@ -23,64 +23,90 @@ import (
2323func getHookTemplates () (hookNames , hookTpls , giteaHookTpls []string ) {
2424 hookNames = []string {"pre-receive" , "update" , "post-receive" }
2525 hookTpls = []string {
26+ // for pre-receive
2627 fmt .Sprintf (`#!/usr/bin/env %s
28+ # AUTO GENERATED BY GITEA, DO NOT MODIFY
2729data=$(cat)
2830exitcodes=""
2931hookname=$(basename $0)
3032GIT_DIR=${GIT_DIR:-$(dirname $0)/..}
3133
3234for hook in ${GIT_DIR}/hooks/${hookname}.d/*; do
33- test -x "${hook}" && test -f "${hook}" || continue
34- echo "${data}" | "${hook}"
35- exitcodes="${exitcodes} $?"
35+ test -x "${hook}" && test -f "${hook}" || continue
36+ echo "${data}" | "${hook}"
37+ exitcodes="${exitcodes} $?"
3638done
3739
3840for i in ${exitcodes}; do
39- [ ${i} -eq 0 ] || exit ${i}
41+ [ ${i} -eq 0 ] || exit ${i}
4042done
4143` , setting .ScriptType ),
44+
45+ // for update
4246 fmt .Sprintf (`#!/usr/bin/env %s
47+ # AUTO GENERATED BY GITEA, DO NOT MODIFY
4348exitcodes=""
4449hookname=$(basename $0)
4550GIT_DIR=${GIT_DIR:-$(dirname $0/..)}
4651
4752for hook in ${GIT_DIR}/hooks/${hookname}.d/*; do
48- test -x "${hook}" && test -f "${hook}" || continue
49- "${hook}" $1 $2 $3
50- exitcodes="${exitcodes} $?"
53+ test -x "${hook}" && test -f "${hook}" || continue
54+ "${hook}" $1 $2 $3
55+ exitcodes="${exitcodes} $?"
5156done
5257
5358for i in ${exitcodes}; do
54- [ ${i} -eq 0 ] || exit ${i}
59+ [ ${i} -eq 0 ] || exit ${i}
5560done
5661` , setting .ScriptType ),
62+
63+ // for post-receive
5764 fmt .Sprintf (`#!/usr/bin/env %s
65+ # AUTO GENERATED BY GITEA, DO NOT MODIFY
5866data=$(cat)
5967exitcodes=""
6068hookname=$(basename $0)
6169GIT_DIR=${GIT_DIR:-$(dirname $0)/..}
6270
6371for hook in ${GIT_DIR}/hooks/${hookname}.d/*; do
64- test -x "${hook}" && test -f "${hook}" || continue
65- echo "${data}" | "${hook}"
66- exitcodes="${exitcodes} $?"
72+ test -x "${hook}" && test -f "${hook}" || continue
73+ echo "${data}" | "${hook}"
74+ exitcodes="${exitcodes} $?"
6775done
6876
6977for i in ${exitcodes}; do
70- [ ${i} -eq 0 ] || exit ${i}
78+ [ ${i} -eq 0 ] || exit ${i}
7179done
7280` , setting .ScriptType ),
7381 }
82+
7483 giteaHookTpls = []string {
75- fmt .Sprintf ("#!/usr/bin/env %s\n %s hook --config=%s pre-receive\n " , setting .ScriptType , util .ShellEscape (setting .AppPath ), util .ShellEscape (setting .CustomConf )),
76- fmt .Sprintf ("#!/usr/bin/env %s\n %s hook --config=%s update $1 $2 $3\n " , setting .ScriptType , util .ShellEscape (setting .AppPath ), util .ShellEscape (setting .CustomConf )),
77- fmt .Sprintf ("#!/usr/bin/env %s\n %s hook --config=%s post-receive\n " , setting .ScriptType , util .ShellEscape (setting .AppPath ), util .ShellEscape (setting .CustomConf )),
84+ // for pre-receive
85+ fmt .Sprintf (`#!/usr/bin/env %s
86+ # AUTO GENERATED BY GITEA, DO NOT MODIFY
87+ %s hook --config=%s pre-receive
88+ ` , setting .ScriptType , util .ShellEscape (setting .AppPath ), util .ShellEscape (setting .CustomConf )),
89+
90+ // for update
91+ fmt .Sprintf (`#!/usr/bin/env %s
92+ # AUTO GENERATED BY GITEA, DO NOT MODIFY
93+ %s hook --config=%s update $1 $2 $3
94+ ` , setting .ScriptType , util .ShellEscape (setting .AppPath ), util .ShellEscape (setting .CustomConf )),
95+
96+ // for post-receive
97+ fmt .Sprintf (`#!/usr/bin/env %s
98+ # AUTO GENERATED BY GITEA, DO NOT MODIFY
99+ %s hook --config=%s post-receive
100+ ` , setting .ScriptType , util .ShellEscape (setting .AppPath ), util .ShellEscape (setting .CustomConf )),
78101 }
79102
80103 if git .SupportProcReceive {
81104 hookNames = append (hookNames , "proc-receive" )
82105 hookTpls = append (hookTpls ,
83- fmt .Sprintf ("#!/usr/bin/env %s\n %s hook --config=%s proc-receive\n " , setting .ScriptType , util .ShellEscape (setting .AppPath ), util .ShellEscape (setting .CustomConf )))
106+ fmt .Sprintf (`#!/usr/bin/env %s
107+ # AUTO GENERATED BY GITEA, DO NOT MODIFY
108+ %s hook --config=%s proc-receive
109+ ` , setting .ScriptType , util .ShellEscape (setting .AppPath ), util .ShellEscape (setting .CustomConf )))
84110 giteaHookTpls = append (giteaHookTpls , "" )
85111 }
86112
0 commit comments