@@ -153,6 +153,11 @@ ClassMethod PrivateKeyFile() As %String
153
153
quit $get (@..#Storage@(" settings" ," ssh" ," privateKeyFile" ))
154
154
}
155
155
156
+ ClassMethod CompileOnImport () As %Boolean
157
+ {
158
+ quit $get (@..#Storage@(" settings" ," compileOnImport" ),1 )
159
+ }
160
+
156
161
ClassMethod NeedSettings () As %Boolean [ CodeMode = expression ]
157
162
{
158
163
(..TempFolder () = " " ) || (..GitBinPath () = " " ) || (..GitBinPath () = " " " " )
@@ -517,7 +522,7 @@ ClassMethod Pull(remote As %String = "origin") As %Status
517
522
set branchName = outStream .ReadLine (outStream .Size )
518
523
write !, " Pulling from branch: " , branchName
519
524
kill errStream , outStream
520
- set returnCode = ..RunGitWithArgs (.errStream , .outStream , " pull" , remote , branchName )
525
+ set returnCode = ..RunGitWithArgs (.errStream , .outStream , " pull" , remote )
521
526
522
527
w !, " Pull ran with return code: " _ returnCode
523
528
quit $$$OK
@@ -1337,13 +1342,17 @@ ClassMethod ImportRoutines(force As %Boolean = 0) As %Status
1337
1342
1338
1343
#dim ec as %Status = ..ListItemsInFiles (.itemList , .err )
1339
1344
quit :'ec ec
1345
+
1346
+ kill files
1340
1347
1348
+ set settings = ##class (SourceControl.Git.Settings ).%New ()
1341
1349
#dim internalName as %String = " "
1342
1350
for {
1343
1351
set internalName = $order (itemList (internalName ))
1344
1352
quit :internalName =" "
1345
1353
set context = ##class (SourceControl.Git.PackageManagerContext ).ForInternalName (internalName )
1346
1354
continue :context .Package '=refPackage
1355
+ set doImport = ..IsRoutineOutdated (internalName ) || force
1347
1356
if ..IsInSourceControl (internalName ) {
1348
1357
set sc = ..ImportItem (internalName , force )
1349
1358
} else {
@@ -1352,7 +1361,15 @@ ClassMethod ImportRoutines(force As %Boolean = 0) As %Status
1352
1361
if $$$ISERR(sc ) {
1353
1362
set ec = $$$ADDSC(ec , sc )
1354
1363
}
1364
+ if doImport && settings .compileOnImport {
1365
+ set modification = ##class (SourceControl.Git.Modification ).%New ()
1366
+ set modification .changeType = " M"
1367
+ set modification .internalName = internalName
1368
+ set modification .externalName = ..FullExternalName (internalName )
1369
+ set files ($increment (files )) = modification
1370
+ }
1355
1371
}
1372
+
1356
1373
1357
1374
//let's delete all items for which corresponding files had been deleted
1358
1375
#dim item as %String = " "
@@ -1366,41 +1383,21 @@ ClassMethod ImportRoutines(force As %Boolean = 0) As %Status
1366
1383
set fullExternalName = ..FullExternalName (item )
1367
1384
if '##class (%File ).Exists (fullExternalName ) {
1368
1385
write !,fullExternalName ," does not exist - deleting " ,item
1369
- #dim type as %String = ..Type (item )
1370
- #dim name as %String = ..NameWithoutExtension (item )
1371
- #dim deleted as %Boolean = 1
1372
- if type = " prj" {
1373
- set ec = $$$ADDSC(ec , $system .OBJ .DeleteProject (name ))
1374
- }elseif type = " cls" {
1375
- set ec = $$$ADDSC(ec , $system .OBJ .Delete (item ))
1376
- }elseif $listfind ($listbuild (" mac" ," int" ," inc" ," bas" ," mvb" ," mvi" ), type ) > 0 {
1377
- set ec = $$$ADDSC(ec , ##class (%Routine ).Delete (item ))
1378
- }elseif type = " csp" {
1379
- #dim filename = $system .CSP .GetFileName (item )
1380
- if ##class (%File ).Exists (filename ) && '##class (%File ).Delete (filename ) {
1381
- set ec = $$$ADDSC(ec , ..MakeError (" Error while removing " _item ))
1382
- }
1383
- }elseif ..UserTypeCached (item ) {
1384
- set ec = $$$ADDSC(ec , ##class (%Library.RoutineMgr ).Delete (item ))
1385
- } else {
1386
- set deleted = 0
1387
- }
1388
-
1389
- if deleted && ec {
1390
- do ..RemoveRoutineTSH (item )
1391
- kill $$$TrackedItems(..NormalizeExtension (item ))
1392
- write !, item , " was deleted"
1393
- } else {
1394
- if +$system .Status .GetErrorCodes (ec ) '= $$$ClassDoesNotExist {
1395
- write !, " Error: could not delete " , item
1396
- } else {
1397
- // if something we wanted to delete is already deleted -- good!
1398
- set ec = $$$OK
1399
- }
1400
- }
1386
+ set modification = ##class (SourceControl.Git.Modification ).%New ()
1387
+ set modification .changeType = " D"
1388
+ set modification .internalName = item
1389
+ set modification .externalName = fullExternalName
1390
+ set files ($increment (files )) = modification
1401
1391
}
1402
1392
}
1403
1393
1394
+ set eventHandler = $classmethod (..PullEventClass ()," %New" )
1395
+ set eventHandler .LocalRoot = ..TempFolder ()
1396
+ merge eventHandler .ModifiedFiles = files
1397
+ set sc = eventHandler .OnPull ()
1398
+ if $$$ISERR(sc ) {
1399
+ set ec = $$$ADDSC(ec ,sc )
1400
+ }
1404
1401
write !, " ==import done=="
1405
1402
quit ec
1406
1403
}
@@ -1577,10 +1574,6 @@ ClassMethod RunGitCommand(command As %String, Output errStream, Output outStream
1577
1574
1578
1575
ClassMethod RunGitCommandWithInput (command As %String , inFile As %String = " " , Output errStream , Output outStream , args ...) As %Integer
1579
1576
{
1580
- set pullArg = " "
1581
- if command = " pull" {
1582
- set pullArg = $Get (args (1 ))
1583
- }
1584
1577
// Special case: git --version is used internally even when the settings incorporated here may be invalid/unspecified.
1585
1578
if (command '= " --version" ) {
1586
1579
set newArgs ($increment (newArgs )) = " -C"
@@ -1608,44 +1601,43 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
1608
1601
1609
1602
set newArgs ($increment (newArgs )) = command
1610
1603
1611
- // defining variables for if statement use later
1612
- set syncIris = 0
1604
+ set syncIrisWithDiff = 0 // whether IRIS needs to be synced with repo file changes using diff output
1605
+ set syncIrisWithCommand = 0 // // whether IRIS needs to be synced with repo file changes using command output
1613
1606
set diffBase = " "
1614
1607
set diffCompare = " "
1615
- set pullOriginIndex = " "
1616
- if (command = " checkout" ) || (command = " merge" ) || (command = " rebase" ) || (command = " pull" ) {
1617
- set syncIris = 1
1618
- if $data (args ) && $data (args (args ),diffCompare ) {
1619
- // no-op
1620
- }
1608
+
1609
+ if (command = " checkout" ){
1610
+ set syncIrisWithDiff = 1
1611
+ set diffCompare = args (args )
1612
+ } elseif (command = " merge" ) || (command = " rebase" ) || (command = " pull" ){
1613
+ set syncIrisWithCommand = 1
1614
+ set diffCompare = args (args )
1621
1615
}
1622
1616
1623
1617
for i =1 :1 :$get (args ) {
1624
1618
if ($data (args (i ))) {
1625
1619
set newArgs ($increment (newArgs )) = args (i )
1626
- if newArgs (newArgs ) = pullArg {
1627
- set pullOriginIndex = newArgs
1628
- }
1629
- if (args (i ) = " checkout" ) || (args (i ) = " merge" ) || (args (i ) = " rebase" ) || (args (i ) = " pull" ){
1630
- set syncIris = 1
1620
+ if (args (i ) = " checkout" ) {
1621
+ set syncIrisWithDiff = 1
1631
1622
set diffCompare = args (i + 1 )
1632
1623
1633
1624
if args = (i + 2 ) {
1634
1625
set diffBase = args (i + 2 )
1635
1626
}
1627
+ } elseif (args (i ) = " merge" ) || (args (i ) = " rebase" ) || (args (i ) = " pull" ) {
1628
+ set syncIrisWithCommand = 1
1629
+ set diffCompare = args (i + 1 )
1636
1630
}
1637
1631
1638
- if (args (i ) = " pull" ) {
1639
- set pullOriginIndex = i
1640
- }
1641
1632
}
1642
1633
}
1643
1634
1644
- if (diffCompare = " --no-commit" ) || (diffCompare = " --abort" ) {
1645
- set syncIris = 0
1635
+ if (diffCompare = " --no-commit" ) || (diffCompare = " --abort" ) || (diffCompare = " -b" ) {
1636
+ set syncIrisWithDiff = 0
1637
+ set syncIrisWithCommand = 0
1646
1638
}
1647
1639
1648
- if syncIris {
1640
+ if syncIrisWithDiff {
1649
1641
if diffBase = " " {
1650
1642
set diffBase = ..GetCurrentBranch ()
1651
1643
}
@@ -1665,13 +1657,9 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
1665
1657
set modification .internalName = " "
1666
1658
}
1667
1659
set files ($increment (files )) = modification
1668
- set mod = files (files )
1669
1660
write !, ?4 , modification .changeType , ?4 , modification .internalName , ?4 , modification .externalName
1670
1661
}
1671
1662
1672
- if pullOriginIndex '= " " {
1673
- set newArgs (pullOriginIndex ) = $piece (newArgs (pullOriginIndex ), " /" , 1 )
1674
- }
1675
1663
}
1676
1664
1677
1665
set outLog = ##class (%Library.File ).TempFilename ()
@@ -1700,16 +1688,61 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
1700
1688
for stream =errStream ,outStream {
1701
1689
set stream .RemoveOnClose = 1
1702
1690
}
1703
- if syncIris {
1704
- do ..PrintStreams (errStream , outStream )
1705
- $$$ThrowOnError(..SyncIrisWithRepo (.files ))
1691
+ do ..PrintStreams (errStream , outStream )
1692
+ if syncIrisWithDiff {
1693
+ $$$ThrowOnError(..SyncIrisWithRepoThroughDiff (.files ))
1694
+ } elseif syncIrisWithCommand {
1695
+ $$$ThrowOnError(..SyncIrisWithRepoThroughCommand (.outStream ))
1706
1696
}
1707
1697
quit returnCode
1708
1698
}
1709
1699
1710
- ClassMethod SyncIrisWithRepo (ByRef files )
1700
+ ClassMethod SyncIrisWithRepoThroughCommand (ByRef outStream ) As %Status
1711
1701
{
1702
+ set deletedFiles = " "
1703
+ set addedFiles = " "
1704
+ set files = " "
1705
+ while (outStream .AtEnd = 0 ) {
1706
+
1707
+ set line = outStream .ReadLine ()
1708
+ set lineStart = $piece (line , " " , 2 )
1709
+ if (lineStart = " delete" ) || (lineStart = " create" ) {
1710
+ set fileOperation = $select (lineStart = " create" : " A" , 1 : " D" )
1711
+ set externalName = $piece (line , " " , *)
1712
+ set internalName = ##class (SourceControl.Git.Utils ).NameToInternalName (externalName ,,0 )
1713
+ set modification = ##class (SourceControl.Git.Modification ).%New ()
1714
+ set modification .changeType = fileOperation
1715
+ set modification .internalName = internalName
1716
+ set modification .externalName = externalName
1717
+ set files ($i (files )) = modification
1718
+ if fileOperation = " A" {
1719
+ set addedFiles = addedFiles _" ," _internalName
1720
+ } else {
1721
+ set deletedFiles = deletedFiles _" ," _internalName
1722
+ }
1723
+ }
1724
+ }
1725
+
1726
+ set deletedFiles = $extract (deletedFiles , 2 , *)
1727
+ set addedFiles = $extract (addedFiles , 2 , *)
1728
+
1712
1729
1730
+ if (deletedFiles '= " " ){
1731
+ set sc = ##class (SourceControl.Git.Utils ).RemoveFromServerSideSourceControl (deletedFiles )
1732
+ }
1733
+ if (addedFiles '= " " ){
1734
+ set sc = ##class (SourceControl.Git.Utils ).AddToServerSideSourceControl (addedFiles )
1735
+ }
1736
+
1737
+ do outStream .Rewind ()
1738
+ set event = $classmethod (..PullEventClass ()," %New" )
1739
+ set event .LocalRoot = ..TempFolder ()
1740
+ merge event .ModifiedFiles = files
1741
+ quit event .OnPull ()
1742
+ }
1743
+
1744
+ ClassMethod SyncIrisWithRepoThroughDiff (ByRef files ) As %Status
1745
+ {
1713
1746
set key = $order (files (" " ))
1714
1747
set deletedFiles = " "
1715
1748
set addedFiles = " "
0 commit comments