@@ -23,64 +23,90 @@ import (
23
23
func getHookTemplates () (hookNames , hookTpls , giteaHookTpls []string ) {
24
24
hookNames = []string {"pre-receive" , "update" , "post-receive" }
25
25
hookTpls = []string {
26
+ // for pre-receive
26
27
fmt .Sprintf (`#!/usr/bin/env %s
28
+ # AUTO GENERATED BY GITEA, DO NOT MODIFY
27
29
data=$(cat)
28
30
exitcodes=""
29
31
hookname=$(basename $0)
30
32
GIT_DIR=${GIT_DIR:-$(dirname $0)/..}
31
33
32
34
for 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} $?"
36
38
done
37
39
38
40
for i in ${exitcodes}; do
39
- [ ${i} -eq 0 ] || exit ${i}
41
+ [ ${i} -eq 0 ] || exit ${i}
40
42
done
41
43
` , setting .ScriptType ),
44
+
45
+ // for update
42
46
fmt .Sprintf (`#!/usr/bin/env %s
47
+ # AUTO GENERATED BY GITEA, DO NOT MODIFY
43
48
exitcodes=""
44
49
hookname=$(basename $0)
45
50
GIT_DIR=${GIT_DIR:-$(dirname $0/..)}
46
51
47
52
for 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} $?"
51
56
done
52
57
53
58
for i in ${exitcodes}; do
54
- [ ${i} -eq 0 ] || exit ${i}
59
+ [ ${i} -eq 0 ] || exit ${i}
55
60
done
56
61
` , setting .ScriptType ),
62
+
63
+ // for post-receive
57
64
fmt .Sprintf (`#!/usr/bin/env %s
65
+ # AUTO GENERATED BY GITEA, DO NOT MODIFY
58
66
data=$(cat)
59
67
exitcodes=""
60
68
hookname=$(basename $0)
61
69
GIT_DIR=${GIT_DIR:-$(dirname $0)/..}
62
70
63
71
for 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} $?"
67
75
done
68
76
69
77
for i in ${exitcodes}; do
70
- [ ${i} -eq 0 ] || exit ${i}
78
+ [ ${i} -eq 0 ] || exit ${i}
71
79
done
72
80
` , setting .ScriptType ),
73
81
}
82
+
74
83
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 )),
78
101
}
79
102
80
103
if git .SupportProcReceive {
81
104
hookNames = append (hookNames , "proc-receive" )
82
105
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 )))
84
110
giteaHookTpls = append (giteaHookTpls , "" )
85
111
}
86
112
0 commit comments