@@ -198,19 +198,15 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe
198
198
quit $$$OK
199
199
}elseif (menuItemName = " %Push" ) {
200
200
quit ..Push ()
201
- //, Studio still crashes when calling rungitcommand with push as command
202
- //quit $$$OK
203
201
}elseif (menuItemName = " %Fetch" ) {
204
- //TODO: Implement fetch git command
205
202
$$$QuitOnError(..Fetch (.diffFiles ))
206
203
set pointer = 0
207
204
while $ListNext (diffFiles , pointer , item ){
208
205
write !,item
209
206
}
210
207
write !
211
208
}elseif (menuItemName = " %Pull" ) {
212
- //TODO: Implement pull git command
213
- quit $$$OK
209
+ quit ..Pull ()
214
210
}
215
211
elseif ..IsMenuGitCommand (menuItemName ) {
216
212
set Action = 3
@@ -302,8 +298,6 @@ ClassMethod Fetch(ByRef diffFiles) As %Status
302
298
{
303
299
do ..RunGitCommand (" fetch" , .errStream , .outStream )
304
300
w !, " git fetch"
305
- //git diff ..origin --name-only
306
- //another test for push
307
301
kill errStream , outStream
308
302
do ..RunGitCommand (" diff" , .errStream , .outStream , " ..origin" , " --name-only" )
309
303
set diffFiles = " "
@@ -315,8 +309,61 @@ ClassMethod Fetch(ByRef diffFiles) As %Status
315
309
quit $$$OK
316
310
}
317
311
318
- ClassMethod Pull () As %Status
312
+ ClassMethod Pull (remote As %String = " origin " ) As %Status
319
313
{
314
+
315
+ #define Force 1
316
+ do ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" branch" ,,.errStream ,.outStream ," --show-current" )
317
+ set branchName = outStream .ReadLine (outStream .Size )
318
+ write !, " Pulling from branch: " , branchName
319
+
320
+ set sc = ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" fetch" ,,.errStream ,.outStream ,)
321
+ if (sc =1 ){
322
+ do errStream .OutputToDevice ()
323
+ quit sc
324
+ }
325
+
326
+ write !, " Fetch done"
327
+ write !, " Files in diff: "
328
+
329
+ do ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" diff" ,,.errStream ,.outStream ," --name-only" ," .." _remote )
330
+ while (outStream .AtEnd = 0 ) {
331
+ set file = outStream .ReadLine ()
332
+ set files ($I (files )) = file
333
+ write !,?4 , file
334
+ }
335
+
336
+ set sc = ..RunGitWithArgs (.errStream , .outStream , " pull" , remote , branchName )
337
+ if (sc =1 ){
338
+ do errStream .OutputToDevice ()
339
+ do outStream .OutputToDevice ()
340
+ quit $$$ERROR(5001 , " Not compiled. Fix errors before compiling." )
341
+ }
342
+ write !
343
+ do outStream .OutputToDevice ()
344
+ write !
345
+
346
+ set nFiles = 0
347
+ for i =1 :1 :$g (files )
348
+ {
349
+ if ($DATA (files (i ))) {
350
+ set internalName = ..NameToInternalName (files (i ))
351
+ if (internalName = " " ) {
352
+ write files (i ), " was not imported into the database and will not be compiled. " , !
353
+ }
354
+ else {
355
+ set compilelist (internalName ) = " "
356
+ set nFiles = nFiles + 1
357
+ set ec = ..ImportItem (internalName , $$$Force)
358
+ }
359
+ }
360
+ }
361
+
362
+ if (nFiles = 0 ){
363
+ write " Nothing to compile." ,!
364
+ quit $$$OK
365
+ }
366
+ Do $System .OBJ .CompileList (.compilelist , " cukb" )
320
367
quit $$$OK
321
368
}
322
369
@@ -1101,7 +1148,6 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
1101
1148
if ($DATA (args (i ))) {
1102
1149
set newArgs ($i (newArgs )) = args (i )
1103
1150
}
1104
-
1105
1151
}
1106
1152
1107
1153
set outLog = ##class (%Library.File ).TempFilename ()
@@ -1301,4 +1347,3 @@ ClassMethod NameToInternalName(Name, IgnorePercent = 1, IgnoreNonexistent = 1) A
1301
1347
}
1302
1348
1303
1349
}
1304
-
0 commit comments