@@ -236,8 +236,7 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe
236
236
} elseif (menuItemName = " Status" ) {
237
237
do ..RunGitCommand (" status" , .errStream , .outStream )
238
238
write !, !, " Git Status: "
239
- do outStream .OutputToDevice ()
240
- do errStream .OutputToDevice ()
239
+ do ..PrintStreams (outStream , errStream )
241
240
}
242
241
quit ec
243
242
}
@@ -271,10 +270,8 @@ ClassMethod AfterUserAction(Type As %Integer, Name As %String, InternalName As %
271
270
ClassMethod Init () As %Status
272
271
{
273
272
do ..RunGitCommand (" init" ,.errStream ,.outStream )
274
- $$$NewLineIfNonEmptyStream(errStream )
275
- do errStream .OutputToDevice ()
276
- $$$NewLineIfNonEmptyStream(outStream )
277
- do outStream .OutputToDevice ()
273
+ do ..PrintStreams (outStream , errStream )
274
+
278
275
quit $$$OK
279
276
}
280
277
@@ -295,10 +292,7 @@ ClassMethod Commit(InternalName As %String, Message As %String = "example commit
295
292
set email = ..GitUserEmail ()
296
293
set author = username _" <" _email _" >"
297
294
do ..RunGitWithArgs (.errStream , .outStream , " commit" , " --author" , author , " -m" , Message , filename )
298
- $$$NewLineIfNonEmptyStream(outStream )
299
- do outStream .OutputToDevice ()
300
- $$$NewLineIfNonEmptyStream(errStream )
301
- do errStream .OutputToDevice ()
295
+ do ..PrintStreams (outStream , outStream )
302
296
$$$QuitOnError(##class (SourceControl.Git.Change ).RemoveUncommitted (filename ))
303
297
$$$QuitOnError(##class (SourceControl.Git.Change ).RefreshUncommitted ())
304
298
quit $$$OK
@@ -307,20 +301,14 @@ ClassMethod Commit(InternalName As %String, Message As %String = "example commit
307
301
ClassMethod NewBranch (newBranchName As %String ) As %Status
308
302
{
309
303
do ..RunGitWithArgs (.errStream , .outStream , " checkout" , " -b" , newBranchName )
310
- $$$NewLineIfNonEmptyStream(errStream )
311
- do errStream .OutputToDevice ()
312
- $$$NewLineIfNonEmptyStream(outStream )
313
- do outStream .OutputToDevice ()
304
+ do ..PrintStreams (errStream , outStream )
314
305
quit $$$OK
315
306
}
316
307
317
308
ClassMethod SwitchBranch (targetBranchName As %String ) As %Status
318
309
{
319
310
do ..RunGitWithArgs (.errStream , .outStream , " checkout" , targetBranchName )
320
- $$$NewLineIfNonEmptyStream(errStream )
321
- do errStream .OutputToDevice ()
322
- $$$NewLineIfNonEmptyStream(outStream )
323
- do outStream .OutputToDevice ()
311
+ do ..PrintStreams (errStream , outStream )
324
312
quit $$$OK
325
313
}
326
314
@@ -329,10 +317,7 @@ ClassMethod Push(remote As %String = "origin") As %Status
329
317
do ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" branch" ,,.errStream ,.outstream ," --show-current" )
330
318
set branchName = outstream .ReadLine (outstream .Size )
331
319
do ..RunGitWithArgs (.errStream , .outStream , " push" , remote , branchName )
332
- $$$NewLineIfNonEmptyStream(errStream )
333
- do errStream .OutputToDevice ()
334
- $$$NewLineIfNonEmptyStream(outStream )
335
- do outStream .OutputToDevice ()
320
+ do ..PrintStreams (errStream , outStream )
336
321
quit $$$OK
337
322
}
338
323
@@ -358,8 +343,7 @@ ClassMethod Pull(remote As %String = "origin", preview As %Boolean = 0) As %Stat
358
343
359
344
set sc = ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" fetch" ,,.errStream ,.outStream , remote , branchName )
360
345
if (sc =1 ){
361
- $$$NewLineIfNonEmptyStream(errStream )
362
- do errStream .OutputToDevice ()
346
+ do ..PrintStreams (errStream )
363
347
quit sc
364
348
}
365
349
@@ -394,14 +378,10 @@ ClassMethod Pull(remote As %String = "origin", preview As %Boolean = 0) As %Stat
394
378
395
379
set sc = ..RunGitWithArgs (.errStream , .outStream , " pull" , remote , branchName )
396
380
if (sc =1 ){
397
- $$$NewLineIfNonEmptyStream(errStream )
398
- do errStream .OutputToDevice ()
399
- $$$NewLineIfNonEmptyStream(outStream )
400
- do outStream .OutputToDevice ()
381
+ do ..PrintStreams (errStream , outStream )
401
382
quit $$$ERROR(5001 , " Pull event handler not called. Fix errors before compiling." )
402
383
}
403
- $$$NewLineIfNonEmptyStream(outStream )
404
- do outStream .OutputToDevice ()
384
+ do ..PrintStreams (outStream )
405
385
write !
406
386
407
387
set key = $order (files (" " ))
@@ -444,6 +424,7 @@ ClassMethod Clone(remote As %String) As %Status
444
424
set settings = ##class (SourceControl.Git.Settings ).%New ()
445
425
// TODO: eventually use /ENV flag with GIT_TERMINAL_PROMPT=0. (This isn't doc'd yet and is only in really new versions.)
446
426
set sc = ..RunGitWithArgs (.errStream , .outStream , " clone" , remote , settings .namespaceTemp )
427
+ // can I substitute this with the new print method?
447
428
$$$NewLineIfNonEmptyStream(errStream )
448
429
while 'errStream .AtEnd {
449
430
write errStream .ReadLine (),!
@@ -480,8 +461,7 @@ ClassMethod GenerateSSHKeyPair() As %Status
480
461
for stream =errStream ,outStream {
481
462
set stream .RemoveOnClose = 1
482
463
}
483
- do outStream .OutputToDevice ()
484
- do errStream .OutputToDevice ()
464
+ do ..PrintStreams (outStream , errStream )
485
465
quit $$$OK
486
466
}
487
467
@@ -543,10 +523,7 @@ ClassMethod AddToSourceControl(InternalName As %String) As %Status
543
523
set @..#Storage@(" items" , FileInternalName ) = " "
544
524
do ..RunGitCommand (" add" ,.errStream ,.outStream ,filenames (i ))
545
525
write !, " Added " , FileInternalName , " to source control."
546
- $$$NewLineIfNonEmptyStream(outStream )
547
- do outStream .OutputToDevice ()
548
- $$$NewLineIfNonEmptyStream(errStream )
549
- do errStream .OutputToDevice ()
526
+ do ..PrintStreams (outStream , errStream )
550
527
}
551
528
}
552
529
quit ec
@@ -556,10 +533,7 @@ ClassMethod RemoveFromGit(InternalName)
556
533
{
557
534
#dim fullName = ##class (Utils ).FullExternalName (InternalName )
558
535
do ..RunGitCommand (" rm" ,.errStream ,.outStream ," --cached" , fullName )
559
- $$$NewLineIfNonEmptyStream(errStream )
560
- do errStream .OutputToDevice ()
561
- $$$NewLineIfNonEmptyStream(outStream )
562
- do errStream .OutputToDevice ()
536
+ do ..PrintStreams (errStream , outStream )
563
537
}
564
538
565
539
ClassMethod DeleteExternalsForItem (InternalName As %String ) As %Status
@@ -1534,6 +1508,12 @@ ClassMethod GitStatus(ByRef files, IncludeAllFiles = 0)
1534
1508
}
1535
1509
}
1536
1510
1511
+ ClassMethod EmptyInitialCommit ()
1512
+ {
1513
+ set ret = ..RunGitCommandWithInput (" commit" ,, .errStream , .outStream , " --allow-empty" , " -m" , " empty initial commit" )
1514
+ do ..PrintStreams (errStream , outStream )
1515
+ }
1516
+
1537
1517
/*
1538
1518
Internal name: e.g. SourceControl.Git.Utils.CLS
1539
1519
External name e.g. cls/SourceControl/Git/Utils.cls
@@ -1995,6 +1975,15 @@ ClassMethod SetDefaultMappings(mappingsNode As %String)
1995
1975
set @mappingsNode @(" MAC" ," *" )=" rtn/"
1996
1976
}
1997
1977
1978
+ ClassMethod PrintStreams (streams ... As %Stream .FileCharacter )
1979
+ {
1980
+ for i =1 :1 :$get (streams , 0 ) {
1981
+ set stream = streams (i )
1982
+ $$$NewLineIfNonEmptyStream(stream )
1983
+ do stream .OutputToDevice ()
1984
+ }
1985
+ }
1986
+
1998
1987
ClassMethod ResetSourceControlClass ()
1999
1988
{
2000
1989
do ##class (%Studio.SourceControl.Interface ).SourceControlClassSet (" " )
0 commit comments