1
- Class isc .git .GitLab
1
+ Class isc .git .GitLab Extends isc . util . LogUtils
2
2
{
3
3
4
4
ClassMethod getDir () [ CodeMode = expression ]
@@ -18,11 +18,13 @@ ClassMethod load()
18
18
{
19
19
try {
20
20
set dir = ..getDir ()
21
+ do ..executeHooks (.hooks , " before" )
22
+
21
23
do ..log (" Importing dir " _ dir )
22
24
do $system .OBJ .ImportDir (dir , ..getExtWildcard (), " c" , .errors , 1 )
23
25
throw :$get (errors ,0 )'=0 ##class (%Exception.General ).%New (" Load error" )
24
26
25
- do ..init ( )
27
+ do ..executeHooks (. hooks , " after " )
26
28
27
29
$$$TOE(sc , ##class (isc.git.Settings ).setSetting (" commit" , ..getCommit ()))
28
30
@@ -46,6 +48,8 @@ ClassMethod loadDiff()
46
48
halt
47
49
} else {
48
50
set dir = ..getDir ()
51
+ do ..executeHooks (.hooks , " before" )
52
+
49
53
set newCommit = ..getCommit ()
50
54
do ..log (" Importing dir " _ dir )
51
55
do ..log ($$$FormatText(" Loading diff between %1 and %2" , oldCommit , newCommit ))
@@ -69,13 +73,13 @@ ClassMethod loadDiff()
69
73
// To-Do delete
70
74
set deleteCode = ##class (isc.git.Settings ).getSetting (" delete" )
71
75
if (($ll (deleted )>0 ) && (deleteCode '=" " )) {
72
- do $classmethod ($p (deleteCode , " :" ), $p (deleteCode , " :" , 2 ))
76
+ do $classmethod ($p (deleteCode , " :" ), $p (deleteCode , " :" , 2 ), deleted )
73
77
}
74
78
75
79
throw :$$$ISERR(sc ) ##class (%Exception.StatusException ).CreateFromStatus (sc )
76
80
throw :$get (errors ,0 )'=0 ##class (%Exception.General ).%New (" Load error" )
77
81
78
- do ..init ( )
82
+ do ..executeHooks (. hooks , " after " )
79
83
80
84
$$$TOE(sc , ##class (isc.git.Settings ).setSetting (" commit" , ..getCommit ()))
81
85
@@ -88,14 +92,20 @@ ClassMethod loadDiff()
88
92
}
89
93
}
90
94
91
- ClassMethod init ( )
95
+ ClassMethod executeHooks ( Output hooks As %String , method As %String ( VALUELIST = " ,before,after,rollback " ) )
92
96
{
93
- set init = ##class (isc.git.Settings ).getSetting (" init" )
94
- if (init '=" " ) {
95
- do ..log (" Running init code: " _ init )
96
- do $classmethod ($p (init , " :" ), $p (init , " :" , 2 ))
97
+ set hooksDir = ##class (isc.git.Settings ).getSetting (" hooks" )
98
+ if (hooksDir '=" " ) {
99
+ do ..log (" Running init hooks: " _ method )
100
+
101
+ if method = " before" {
102
+ set dir = ..getDir ()
103
+ $$$TOE(sc , ##class (isc.git.hook.Manager ).execute (dir _ hooksDir , .hooks , " before" ))
104
+ } elseif method = " after" {
105
+ $$$TOE(sc , ##class (isc.git.hook.Manager ).execute (, .hooks , " after" ))
106
+ }
97
107
} else {
98
- do ..log (" No init code " )
108
+ do ..log (" No hooks " )
99
109
}
100
110
}
101
111
@@ -190,33 +200,5 @@ If you are not redirected automatically, follow this <a href='!!!'>link to tests
190
200
</html >
191
201
}
192
202
193
- ClassMethod logVar (var = " " , name As %String = " " ) As %String
194
- {
195
- do ..log (" Variable " _ name )
196
- zw var
197
- /*if $isObject(var) {
198
- zw var
199
- } elseif $listValid(var) {
200
- write $lts(var, ", ")
201
- } else {
202
- write var
203
- }*/
204
- }
205
-
206
- ClassMethod logException (ex As %Exception .AbstractException )
207
- {
208
- do ..logStatus (ex .AsStatus ())
209
- }
210
-
211
- ClassMethod logStatus (sc As %Status )
212
- {
213
- do ..log ($System .Status .GetErrorText (sc ))
214
- }
215
-
216
- ClassMethod log (msg As %String )
217
- {
218
- write !, $$$FormatText(" [%1] %2" , $zdatetime ($ztimestamp , 3 , 1 , 3 ), msg ), !
219
- }
220
-
221
203
}
222
204
0 commit comments