@@ -156,7 +156,7 @@ $Find(..#ImportAfterGitMenuItems, ","_menuItemName_",") > 0
156
156
ClassMethod UserAction (InternalName As %String , MenuName As %String , ByRef Target As %String , ByRef Action As %String , ByRef Reload As %Boolean ) As %Status
157
157
{
158
158
#define Force 1
159
- #dim menuName as %String = $piece ( MenuName , " , " )
159
+ // MenuName = "<Name of menu>,<Name of menu item>"
160
160
#dim menuItemName as %String = $piece (MenuName ," ," ,2 )
161
161
#dim ec as %Status = $$$OK
162
162
@@ -238,10 +238,10 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe
238
238
set ec = ..AddToSourceControl (InternalName )
239
239
} elseif (menuItemName = " RemoveFromSC" ) {
240
240
set ec = ..RemoveFromSourceControl (InternalName )
241
- } elseif (menuItemName = " Commit " ) {
242
- set Target = " Please enter a commit message "
243
- set Action = 7
244
- quit $$$OK
241
+ } elseif (menuItemName = " Status " ) {
242
+ do .. RunGitCommand ( " status " , . errStream , . outStream )
243
+ write !, !, " Git Status: "
244
+ do .. PrintStreams ( outStream , errStream )
245
245
}
246
246
quit ec
247
247
}
@@ -275,10 +275,8 @@ ClassMethod AfterUserAction(Type As %Integer, Name As %String, InternalName As %
275
275
ClassMethod Init () As %Status
276
276
{
277
277
do ..RunGitCommand (" init" ,.errStream ,.outStream )
278
- $$$NewLineIfNonEmptyStream(errStream )
279
- do errStream .OutputToDevice ()
280
- $$$NewLineIfNonEmptyStream(outStream )
281
- do outStream .OutputToDevice ()
278
+ do ..PrintStreams (outStream , errStream )
279
+
282
280
quit $$$OK
283
281
}
284
282
@@ -299,10 +297,7 @@ ClassMethod Commit(InternalName As %String, Message As %String = "example commit
299
297
set email = ..GitUserEmail ()
300
298
set author = username _" <" _email _" >"
301
299
do ..RunGitWithArgs (.errStream , .outStream , " commit" , " --author" , author , " -m" , Message , filename )
302
- $$$NewLineIfNonEmptyStream(outStream )
303
- do outStream .OutputToDevice ()
304
- $$$NewLineIfNonEmptyStream(errStream )
305
- do errStream .OutputToDevice ()
300
+ do ..PrintStreams (outStream , outStream )
306
301
$$$QuitOnError(##class (SourceControl.Git.Change ).RemoveUncommitted (filename ))
307
302
$$$QuitOnError(##class (SourceControl.Git.Change ).RefreshUncommitted ())
308
303
quit $$$OK
@@ -311,20 +306,14 @@ ClassMethod Commit(InternalName As %String, Message As %String = "example commit
311
306
ClassMethod NewBranch (newBranchName As %String ) As %Status
312
307
{
313
308
do ..RunGitWithArgs (.errStream , .outStream , " checkout" , " -b" , newBranchName )
314
- $$$NewLineIfNonEmptyStream(errStream )
315
- do errStream .OutputToDevice ()
316
- $$$NewLineIfNonEmptyStream(outStream )
317
- do outStream .OutputToDevice ()
309
+ do ..PrintStreams (errStream , outStream )
318
310
quit $$$OK
319
311
}
320
312
321
313
ClassMethod SwitchBranch (targetBranchName As %String ) As %Status
322
314
{
323
315
do ..RunGitWithArgs (.errStream , .outStream , " checkout" , targetBranchName )
324
- $$$NewLineIfNonEmptyStream(errStream )
325
- do errStream .OutputToDevice ()
326
- $$$NewLineIfNonEmptyStream(outStream )
327
- do outStream .OutputToDevice ()
316
+ do ..PrintStreams (errStream , outStream )
328
317
quit $$$OK
329
318
}
330
319
@@ -333,10 +322,7 @@ ClassMethod Push(remote As %String = "origin") As %Status
333
322
do ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" branch" ,,.errStream ,.outstream ," --show-current" )
334
323
set branchName = outstream .ReadLine (outstream .Size )
335
324
do ..RunGitWithArgs (.errStream , .outStream , " push" , remote , branchName )
336
- $$$NewLineIfNonEmptyStream(errStream )
337
- do errStream .OutputToDevice ()
338
- $$$NewLineIfNonEmptyStream(outStream )
339
- do outStream .OutputToDevice ()
325
+ do ..PrintStreams (errStream , outStream )
340
326
quit $$$OK
341
327
}
342
328
@@ -362,8 +348,7 @@ ClassMethod Pull(remote As %String = "origin", preview As %Boolean = 0) As %Stat
362
348
363
349
set sc = ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" fetch" ,,.errStream ,.outStream , remote , branchName )
364
350
if (sc =1 ){
365
- $$$NewLineIfNonEmptyStream(errStream )
366
- do errStream .OutputToDevice ()
351
+ do ..PrintStreams (errStream )
367
352
quit sc
368
353
}
369
354
@@ -398,14 +383,10 @@ ClassMethod Pull(remote As %String = "origin", preview As %Boolean = 0) As %Stat
398
383
399
384
set sc = ..RunGitWithArgs (.errStream , .outStream , " pull" , remote , branchName )
400
385
if (sc =1 ){
401
- $$$NewLineIfNonEmptyStream(errStream )
402
- do errStream .OutputToDevice ()
403
- $$$NewLineIfNonEmptyStream(outStream )
404
- do outStream .OutputToDevice ()
386
+ do ..PrintStreams (errStream , outStream )
405
387
quit $$$ERROR(5001 , " Pull event handler not called. Fix errors before compiling." )
406
388
}
407
- $$$NewLineIfNonEmptyStream(outStream )
408
- do outStream .OutputToDevice ()
389
+ do ..PrintStreams (outStream )
409
390
write !
410
391
411
392
set key = $order (files (" " ))
@@ -448,6 +429,7 @@ ClassMethod Clone(remote As %String) As %Status
448
429
set settings = ##class (SourceControl.Git.Settings ).%New ()
449
430
// TODO: eventually use /ENV flag with GIT_TERMINAL_PROMPT=0. (This isn't doc'd yet and is only in really new versions.)
450
431
set sc = ..RunGitWithArgs (.errStream , .outStream , " clone" , remote , settings .namespaceTemp )
432
+ // can I substitute this with the new print method?
451
433
$$$NewLineIfNonEmptyStream(errStream )
452
434
while 'errStream .AtEnd {
453
435
write errStream .ReadLine (),!
@@ -484,8 +466,7 @@ ClassMethod GenerateSSHKeyPair() As %Status
484
466
for stream =errStream ,outStream {
485
467
set stream .RemoveOnClose = 1
486
468
}
487
- do outStream .OutputToDevice ()
488
- do errStream .OutputToDevice ()
469
+ do ..PrintStreams (outStream , errStream )
489
470
quit $$$OK
490
471
}
491
472
@@ -547,10 +528,7 @@ ClassMethod AddToSourceControl(InternalName As %String) As %Status
547
528
set @..#Storage@(" items" , FileInternalName ) = " "
548
529
do ..RunGitCommand (" add" ,.errStream ,.outStream ,filenames (i ))
549
530
write !, " Added " , FileInternalName , " to source control."
550
- $$$NewLineIfNonEmptyStream(outStream )
551
- do outStream .OutputToDevice ()
552
- $$$NewLineIfNonEmptyStream(errStream )
553
- do errStream .OutputToDevice ()
531
+ do ..PrintStreams (outStream , errStream )
554
532
}
555
533
}
556
534
quit ec
@@ -560,10 +538,7 @@ ClassMethod RemoveFromGit(InternalName)
560
538
{
561
539
#dim fullName = ##class (Utils ).FullExternalName (InternalName )
562
540
do ..RunGitCommand (" rm" ,.errStream ,.outStream ," --cached" , fullName )
563
- $$$NewLineIfNonEmptyStream(errStream )
564
- do errStream .OutputToDevice ()
565
- $$$NewLineIfNonEmptyStream(outStream )
566
- do errStream .OutputToDevice ()
541
+ do ..PrintStreams (errStream , outStream )
567
542
}
568
543
569
544
ClassMethod DeleteExternalsForItem (InternalName As %String ) As %Status
@@ -1031,6 +1006,10 @@ ClassMethod RoutineTSH(InternalName As %String) As %String
1031
1006
#dim type = ..Type (InternalName )
1032
1007
//for csp-files (csp,js,html,css, all that stored in csp/...) we always check for changes in external file
1033
1008
#dim tsh = $case (type ," csp" :" " ,:$get (@..#Storage@(" TSH" , ..NormalizeExtension (InternalName ))))
1009
+
1010
+ // in case an OS level error is returned
1011
+ set :(($$$isUNIX & (tsh = -2 )) || ($$$isWINDOWS & (tsh = -3 ))) tsh = 0
1012
+
1034
1013
if tsh = " " {
1035
1014
#dim ts as %String = ##class (%RoutineMgr ).TS (InternalName )
1036
1015
if ts '= " " {
@@ -1538,6 +1517,12 @@ ClassMethod GitStatus(ByRef files, IncludeAllFiles = 0)
1538
1517
}
1539
1518
}
1540
1519
1520
+ ClassMethod EmptyInitialCommit ()
1521
+ {
1522
+ set ret = ..RunGitCommandWithInput (" commit" ,, .errStream , .outStream , " --allow-empty" , " -m" , " empty initial commit" )
1523
+ do ..PrintStreams (errStream , outStream )
1524
+ }
1525
+
1541
1526
/*
1542
1527
Internal name: e.g. SourceControl.Git.Utils.CLS
1543
1528
External name e.g. cls/SourceControl/Git/Utils.cls
@@ -1991,5 +1976,26 @@ ClassMethod BuildCEInstallationPackage(ByRef destination As %String) As %Status
1991
1976
quit sc
1992
1977
}
1993
1978
1979
+ ClassMethod SetDefaultMappings (mappingsNode As %String )
1980
+ {
1981
+ set @mappingsNode @(" CLS" ," *" )=" cls/"
1982
+ set @mappingsNode @(" CLS" ," UnitTest" )=" test/"
1983
+ set @mappingsNode @(" INC" ," *" )=" inc/"
1984
+ set @mappingsNode @(" MAC" ," *" )=" rtn/"
1985
+ }
1986
+
1987
+ ClassMethod PrintStreams (streams ... As %Stream .FileCharacter )
1988
+ {
1989
+ for i =1 :1 :$get (streams , 0 ) {
1990
+ set stream = streams (i )
1991
+ $$$NewLineIfNonEmptyStream(stream )
1992
+ do stream .OutputToDevice ()
1993
+ }
1994
+ }
1995
+
1996
+ ClassMethod ResetSourceControlClass ()
1997
+ {
1998
+ do ##class (%Studio.SourceControl.Interface ).SourceControlClassSet (" " )
1994
1999
}
1995
2000
2001
+ }
0 commit comments