@@ -475,7 +475,7 @@ ClassMethod Pull(remote As %String = "origin") As %Status
475
475
set branchName = outStream .ReadLine (outStream .Size )
476
476
write !, " Pulling from branch: " , branchName
477
477
kill errStream , outStream
478
- set returnCode = ..RunGitWithArgs (.errStream , .outStream , " pull" , remote _ " / " _ branchName )
478
+ set returnCode = ..RunGitWithArgs (.errStream , .outStream , " pull" , remote )
479
479
480
480
w !, " Pull ran with return code: " _ returnCode
481
481
quit $$$OK
@@ -1534,10 +1534,6 @@ ClassMethod RunGitCommand(command As %String, Output errStream, Output outStream
1534
1534
1535
1535
ClassMethod RunGitCommandWithInput (command As %String , inFile As %String = " " , Output errStream , Output outStream , args ...) As %Integer
1536
1536
{
1537
- set pullArg = " "
1538
- if command = " pull" {
1539
- set pullArg = args (1 )
1540
- }
1541
1537
// Special case: git --version is used internally even when the settings incorporated here may be invalid/unspecified.
1542
1538
if (command '= " --version" ) {
1543
1539
set newArgs ($increment (newArgs )) = " -C"
@@ -1565,43 +1561,44 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
1565
1561
1566
1562
set newArgs ($increment (newArgs )) = command
1567
1563
1568
- // defining variables for if statement use later
1569
- set syncIris = 0
1564
+ set syncIrisWithDiff = 0 // whether IRIS needs to be synced with repo file changes using diff output
1565
+ set syncIrisWithCommand = 0 // // whether IRIS needs to be synced with repo file changes using command output
1570
1566
set diffBase = " "
1571
1567
set diffCompare = " "
1572
- set pullOriginIndex = " "
1573
- if (command = " checkout" ) || (command = " merge" ) || (command = " rebase" ) || (command = " pull" ){
1574
- set syncIris = 1
1568
+
1569
+ if (command = " checkout" ){
1570
+ set syncIrisWithDiff = 1
1571
+ set diffCompare = args (args )
1572
+ } elseif (command = " merge" ) || (command = " rebase" ) || (command = " pull" ){
1573
+ set syncIrisWithCommand = 1
1575
1574
set diffCompare = args (args )
1576
1575
}
1577
1576
1578
1577
1579
1578
for i =1 :1 :$get (args ) {
1580
1579
if ($data (args (i ))) {
1581
1580
set newArgs ($increment (newArgs )) = args (i )
1582
- if newArgs (newArgs ) = pullArg {
1583
- set pullOriginIndex = newArgs
1584
- }
1585
- if (args (i ) = " checkout" ) || (args (i ) = " merge" ) || (args (i ) = " rebase" ) || (args (i ) = " pull" ){
1586
- set syncIris = 1
1581
+ if (args (i ) = " checkout" ) {
1582
+ set syncIrisWithDiff = 1
1587
1583
set diffCompare = args (i + 1 )
1588
1584
1589
1585
if args = (i + 2 ) {
1590
1586
set diffBase = args (i + 2 )
1591
1587
}
1588
+ } elseif (args (i ) = " merge" ) || (args (i ) = " rebase" ) || (args (i ) = " pull" ) {
1589
+ set syncIrisWithCommand = 1
1590
+ set diffCompare = args (i + 1 )
1592
1591
}
1593
1592
1594
- if (args (i ) = " pull" ) {
1595
- set pullOriginIndex = i
1596
- }
1597
1593
}
1598
1594
}
1599
1595
1600
- if (diffCompare = " --no-commit" ) || (diffCompare = " --abort" ) {
1601
- set syncIris = 0
1596
+ if (diffCompare = " --no-commit" ) || (diffCompare = " --abort" ) || (diffCompare = " -b" ) {
1597
+ set syncIrisWithDiff = 0
1598
+ set syncIrisWithCommand = 0
1602
1599
}
1603
1600
1604
- if syncIris {
1601
+ if syncIrisWithDiff {
1605
1602
if diffBase = " " {
1606
1603
set diffBase = ..GetCurrentBranch ()
1607
1604
}
@@ -1621,13 +1618,9 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
1621
1618
set modification .internalName = " "
1622
1619
}
1623
1620
set files ($increment (files )) = modification
1624
- set mod = files (files )
1625
1621
write !, ?4 , modification .changeType , ?4 , modification .internalName , ?4 , modification .externalName
1626
1622
}
1627
1623
1628
- if pullOriginIndex '= " " {
1629
- set newArgs (pullOriginIndex ) = $piece (newArgs (pullOriginIndex ), " /" , 1 )
1630
- }
1631
1624
}
1632
1625
1633
1626
set outLog = ##class (%Library.File ).TempFilename ()
@@ -1657,15 +1650,60 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
1657
1650
set stream .RemoveOnClose = 1
1658
1651
}
1659
1652
do ..PrintStreams (errStream , outStream )
1660
- if syncIris {
1661
- $$$ThrowOnError(..SyncIrisWithRepo (.files ))
1653
+ if syncIrisWithDiff {
1654
+ $$$ThrowOnError(..SyncIrisWithRepoThroughDiff (.files ))
1655
+ } elseif syncIrisWithCommand {
1656
+ $$$ThrowOnError(..SyncIrisWithRepoThroughCommand (.outStream ))
1662
1657
}
1663
1658
quit returnCode
1664
1659
}
1665
1660
1666
- ClassMethod SyncIrisWithRepo (ByRef files )
1661
+ ClassMethod SyncIrisWithRepoThroughCommand (ByRef outStream ) As %Status
1667
1662
{
1663
+ set deletedFiles = " "
1664
+ set addedFiles = " "
1665
+ set files = " "
1666
+ while (outStream .AtEnd = 0 ) {
1667
+
1668
+ set line = outStream .ReadLine ()
1669
+ set lineStart = $piece (line , " " , 2 )
1670
+ if (lineStart = " delete" ) || (lineStart = " create" ) {
1671
+ set fileOperation = $select (lineStart = " create" : " A" , 1 : " D" )
1672
+ set externalName = $piece (line , " " , *)
1673
+ set internalName = ##class (SourceControl.Git.Utils ).NameToInternalName (externalName ,,0 )
1674
+ set modification = ##class (SourceControl.Git.Modification ).%New ()
1675
+ set modification .changeType = fileOperation
1676
+ set modification .internalName = internalName
1677
+ set modification .externalName = externalName
1678
+ set files ($i (files )) = modification
1679
+ if fileOperation = " A" {
1680
+ set addedFiles = addedFiles _" ," _internalName
1681
+ } else {
1682
+ set deletedFiles = deletedFiles _" ," _internalName
1683
+ }
1684
+ }
1685
+ }
1686
+
1687
+ set deletedFiles = $extract (deletedFiles , 2 , *)
1688
+ set addedFiles = $extract (addedFiles , 2 , *)
1689
+
1690
+
1691
+ if (deletedFiles '= " " ){
1692
+ set sc = ##class (SourceControl.Git.Utils ).RemoveFromServerSideSourceControl (deletedFiles )
1693
+ }
1694
+ if (addedFiles '= " " ){
1695
+ set sc = ##class (SourceControl.Git.Utils ).AddToServerSideSourceControl (addedFiles )
1696
+ }
1668
1697
1698
+ do outStream .Rewind ()
1699
+ set event = $classmethod (..PullEventClass ()," %New" )
1700
+ set event .LocalRoot = ..TempFolder ()
1701
+ merge event .ModifiedFiles = files
1702
+ quit event .OnPull ()
1703
+ }
1704
+
1705
+ ClassMethod SyncIrisWithRepoThroughDiff (ByRef files ) As %Status
1706
+ {
1669
1707
set key = $order (files (" " ))
1670
1708
set deletedFiles = " "
1671
1709
set addedFiles = " "
@@ -2348,3 +2386,4 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status
2348
2386
}
2349
2387
2350
2388
}
2389
+
0 commit comments