@@ -151,7 +151,7 @@ $Find(..#ImportAfterGitMenuItems, ","_menuItemName_",") > 0
151
151
ClassMethod UserAction (InternalName As %String , MenuName As %String , ByRef Target As %String , ByRef Action As %String , ByRef Reload As %Boolean ) As %Status
152
152
{
153
153
#define Force 1
154
- #dim menuName as %String = $piece ( MenuName , " , " )
154
+ // MenuName = "<Name of menu>,<Name of menu item>"
155
155
#dim menuItemName as %String = $piece (MenuName ," ," ,2 )
156
156
#dim ec as %Status = $$$OK
157
157
@@ -233,6 +233,10 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe
233
233
set ec = ..AddToSourceControl (InternalName )
234
234
} elseif (menuItemName = " RemoveFromSC" ) {
235
235
set ec = ..RemoveFromSourceControl (InternalName )
236
+ } elseif (menuItemName = " Status" ) {
237
+ do ..RunGitCommand (" status" , .errStream , .outStream )
238
+ write !, !, " Git Status: "
239
+ do ..PrintStreams (outStream , errStream )
236
240
}
237
241
quit ec
238
242
}
@@ -266,10 +270,8 @@ ClassMethod AfterUserAction(Type As %Integer, Name As %String, InternalName As %
266
270
ClassMethod Init () As %Status
267
271
{
268
272
do ..RunGitCommand (" init" ,.errStream ,.outStream )
269
- $$$NewLineIfNonEmptyStream(errStream )
270
- do errStream .OutputToDevice ()
271
- $$$NewLineIfNonEmptyStream(outStream )
272
- do outStream .OutputToDevice ()
273
+ do ..PrintStreams (outStream , errStream )
274
+
273
275
quit $$$OK
274
276
}
275
277
@@ -290,10 +292,7 @@ ClassMethod Commit(InternalName As %String, Message As %String = "example commit
290
292
set email = ..GitUserEmail ()
291
293
set author = username _" <" _email _" >"
292
294
do ..RunGitWithArgs (.errStream , .outStream , " commit" , " --author" , author , " -m" , Message , filename )
293
- $$$NewLineIfNonEmptyStream(outStream )
294
- do outStream .OutputToDevice ()
295
- $$$NewLineIfNonEmptyStream(errStream )
296
- do errStream .OutputToDevice ()
295
+ do ..PrintStreams (outStream , outStream )
297
296
$$$QuitOnError(##class (SourceControl.Git.Change ).RemoveUncommitted (filename ))
298
297
$$$QuitOnError(##class (SourceControl.Git.Change ).RefreshUncommitted ())
299
298
quit $$$OK
@@ -302,20 +301,14 @@ ClassMethod Commit(InternalName As %String, Message As %String = "example commit
302
301
ClassMethod NewBranch (newBranchName As %String ) As %Status
303
302
{
304
303
do ..RunGitWithArgs (.errStream , .outStream , " checkout" , " -b" , newBranchName )
305
- $$$NewLineIfNonEmptyStream(errStream )
306
- do errStream .OutputToDevice ()
307
- $$$NewLineIfNonEmptyStream(outStream )
308
- do outStream .OutputToDevice ()
304
+ do ..PrintStreams (errStream , outStream )
309
305
quit $$$OK
310
306
}
311
307
312
308
ClassMethod SwitchBranch (targetBranchName As %String ) As %Status
313
309
{
314
310
do ..RunGitWithArgs (.errStream , .outStream , " checkout" , targetBranchName )
315
- $$$NewLineIfNonEmptyStream(errStream )
316
- do errStream .OutputToDevice ()
317
- $$$NewLineIfNonEmptyStream(outStream )
318
- do outStream .OutputToDevice ()
311
+ do ..PrintStreams (errStream , outStream )
319
312
quit $$$OK
320
313
}
321
314
@@ -324,10 +317,7 @@ ClassMethod Push(remote As %String = "origin") As %Status
324
317
do ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" branch" ,,.errStream ,.outstream ," --show-current" )
325
318
set branchName = outstream .ReadLine (outstream .Size )
326
319
do ..RunGitWithArgs (.errStream , .outStream , " push" , remote , branchName )
327
- $$$NewLineIfNonEmptyStream(errStream )
328
- do errStream .OutputToDevice ()
329
- $$$NewLineIfNonEmptyStream(outStream )
330
- do outStream .OutputToDevice ()
320
+ do ..PrintStreams (errStream , outStream )
331
321
quit $$$OK
332
322
}
333
323
@@ -353,8 +343,7 @@ ClassMethod Pull(remote As %String = "origin", preview As %Boolean = 0) As %Stat
353
343
354
344
set sc = ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" fetch" ,,.errStream ,.outStream , remote , branchName )
355
345
if (sc =1 ){
356
- $$$NewLineIfNonEmptyStream(errStream )
357
- do errStream .OutputToDevice ()
346
+ do ..PrintStreams (errStream )
358
347
quit sc
359
348
}
360
349
@@ -389,14 +378,10 @@ ClassMethod Pull(remote As %String = "origin", preview As %Boolean = 0) As %Stat
389
378
390
379
set sc = ..RunGitWithArgs (.errStream , .outStream , " pull" , remote , branchName )
391
380
if (sc =1 ){
392
- $$$NewLineIfNonEmptyStream(errStream )
393
- do errStream .OutputToDevice ()
394
- $$$NewLineIfNonEmptyStream(outStream )
395
- do outStream .OutputToDevice ()
381
+ do ..PrintStreams (errStream , outStream )
396
382
quit $$$ERROR(5001 , " Pull event handler not called. Fix errors before compiling." )
397
383
}
398
- $$$NewLineIfNonEmptyStream(outStream )
399
- do outStream .OutputToDevice ()
384
+ do ..PrintStreams (outStream )
400
385
write !
401
386
402
387
set key = $order (files (" " ))
@@ -439,6 +424,7 @@ ClassMethod Clone(remote As %String) As %Status
439
424
set settings = ##class (SourceControl.Git.Settings ).%New ()
440
425
// TODO: eventually use /ENV flag with GIT_TERMINAL_PROMPT=0. (This isn't doc'd yet and is only in really new versions.)
441
426
set sc = ..RunGitWithArgs (.errStream , .outStream , " clone" , remote , settings .namespaceTemp )
427
+ // can I substitute this with the new print method?
442
428
$$$NewLineIfNonEmptyStream(errStream )
443
429
while 'errStream .AtEnd {
444
430
write errStream .ReadLine (),!
@@ -475,8 +461,7 @@ ClassMethod GenerateSSHKeyPair() As %Status
475
461
for stream =errStream ,outStream {
476
462
set stream .RemoveOnClose = 1
477
463
}
478
- do outStream .OutputToDevice ()
479
- do errStream .OutputToDevice ()
464
+ do ..PrintStreams (outStream , errStream )
480
465
quit $$$OK
481
466
}
482
467
@@ -538,10 +523,7 @@ ClassMethod AddToSourceControl(InternalName As %String) As %Status
538
523
set @..#Storage@(" items" , FileInternalName ) = " "
539
524
do ..RunGitCommand (" add" ,.errStream ,.outStream ,filenames (i ))
540
525
write !, " Added " , FileInternalName , " to source control."
541
- $$$NewLineIfNonEmptyStream(outStream )
542
- do outStream .OutputToDevice ()
543
- $$$NewLineIfNonEmptyStream(errStream )
544
- do errStream .OutputToDevice ()
526
+ do ..PrintStreams (outStream , errStream )
545
527
}
546
528
}
547
529
quit ec
@@ -551,10 +533,7 @@ ClassMethod RemoveFromGit(InternalName)
551
533
{
552
534
#dim fullName = ##class (Utils ).FullExternalName (InternalName )
553
535
do ..RunGitCommand (" rm" ,.errStream ,.outStream ," --cached" , fullName )
554
- $$$NewLineIfNonEmptyStream(errStream )
555
- do errStream .OutputToDevice ()
556
- $$$NewLineIfNonEmptyStream(outStream )
557
- do errStream .OutputToDevice ()
536
+ do ..PrintStreams (errStream , outStream )
558
537
}
559
538
560
539
ClassMethod DeleteExternalsForItem (InternalName As %String ) As %Status
@@ -1529,6 +1508,12 @@ ClassMethod GitStatus(ByRef files, IncludeAllFiles = 0)
1529
1508
}
1530
1509
}
1531
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
+
1532
1517
/*
1533
1518
Internal name: e.g. SourceControl.Git.Utils.CLS
1534
1519
External name e.g. cls/SourceControl/Git/Utils.cls
@@ -1990,5 +1975,18 @@ ClassMethod SetDefaultMappings(mappingsNode As %String)
1990
1975
set @mappingsNode @(" MAC" ," *" )=" rtn/"
1991
1976
}
1992
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
+ }
1993
1985
}
1994
1986
1987
+ ClassMethod ResetSourceControlClass ()
1988
+ {
1989
+ do ##class (%Studio.SourceControl.Interface ).SourceControlClassSet (" " )
1990
+ }
1991
+
1992
+ }
0 commit comments