@@ -436,6 +436,9 @@ ClassMethod MergeDefaultRemoteBranch(Output alert As %String = "") As %Boolean
436
436
do ..RunGitWithArgs (.errStream , .outStream , " fetch" , " origin" , defaultMergeBranch _" :" _defaultMergeBranch )
437
437
do ..PrintStreams (errStream , outStream )
438
438
439
+ do ..RunGitWithArgs (,.outStream , " rev-parse" , defaultMergeBranch )
440
+ set startSha = outStream .ReadLine ()
441
+
439
442
// Start a transaction so code changes can be rolled back
440
443
set initTLevel = $TLevel
441
444
try {
@@ -461,7 +464,11 @@ ClassMethod MergeDefaultRemoteBranch(Output alert As %String = "") As %Boolean
461
464
while $TLevel > initTLevel {
462
465
TROLLBACK 1
463
466
}
464
- if 'rebased {
467
+ if rebased {
468
+ do ##class (SourceControl.Git.Utils ).RunGitWithArgs (.errStream , .outStream , " diff" , startSha , " HEAD" , " --name-status" )
469
+ do ##class (SourceControl.Git.Utils ).ParseDiffStream (outStream ,,.finalFileSet )
470
+ do ##class (SourceControl.Git.Utils ).SyncIrisWithRepoThroughDiff (.finalFileSet )
471
+ } else {
465
472
do ..RunGitCommand (" rebase" ,.errStream , .outStream ," --abort" )
466
473
do ..PrintStreams (errStream , outStream )
467
474
set alert = " WARNING: Remote branch '" _defaultMergeBranch _" ' could not be merged due to conflicts. Changes have been pushed to '" _..GetCurrentBranch ()_" ' and must be resolved in your git remote. See log for more details."
@@ -1668,29 +1675,7 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
1668
1675
do ..RunGitCommand (" fetch" , .errorStream , .outputStream )
1669
1676
kill errorStream , outputStream
1670
1677
do ##class (SourceControl.Git.Utils ).RunGitCommandWithInput (" diff" ,,.errorStream ,.outputStream , diffBase _$Case (diffCompare ," " :" " ,:" .." )_diffCompare , " --name-status" )
1671
- while (outputStream .AtEnd = 0 ) {
1672
- set file = outputStream .ReadLine ()
1673
- set modification = ##class (SourceControl.Git.Modification ).%New ()
1674
- set modification .changeType = $piece (file , $c (9 ), 1 )
1675
-
1676
- set modification .externalName = $zstrip ($piece (file , $c (9 ), 2 )," <W" )
1677
- if $extract (modification .changeType ) = " R" {
1678
- set modification .changeType = " D"
1679
- set modification .internalName = ##class (SourceControl.Git.Utils ).NameToInternalName (modification .externalName ,,0 )
1680
- set files ($increment (files )) = modification
1681
- set modification = ##class (SourceControl.Git.Modification ).%New ()
1682
- set modification .changeType = " A"
1683
- set modification .internalName = " "
1684
- set modification .externalName = $zstrip ($piece (file , $c (9 ), 3 )," <W" )
1685
- } elseif (modification .changeType '= " A" ){
1686
- set modification .internalName = ##class (SourceControl.Git.Utils ).NameToInternalName (modification .externalName ,,0 )
1687
- } else {
1688
- set modification .internalName = " "
1689
- }
1690
- set files ($increment (files )) = modification
1691
- write !, ?4 , modification .changeType , ?4 , modification .internalName , ?4 , modification .externalName
1692
- }
1693
-
1678
+ do ..ParseDiffStream (outputStream ,,.files )
1694
1679
}
1695
1680
1696
1681
set outLog = ##class (%Library.File ).TempFilename ()
@@ -1735,8 +1720,8 @@ ClassMethod SyncIrisWithRepoThroughCommand(ByRef outStream) As %Status
1735
1720
set deletedFiles = " "
1736
1721
set addedFiles = " "
1737
1722
set files = " "
1723
+ do outStream .Rewind ()
1738
1724
while (outStream .AtEnd = 0 ) {
1739
-
1740
1725
set line = outStream .ReadLine ()
1741
1726
set lineStart = $piece (line , " " , 2 )
1742
1727
if (lineStart = " delete" ) || (lineStart = " create" ) {
@@ -1759,7 +1744,6 @@ ClassMethod SyncIrisWithRepoThroughCommand(ByRef outStream) As %Status
1759
1744
set deletedFiles = $extract (deletedFiles , 2 , *)
1760
1745
set addedFiles = $extract (addedFiles , 2 , *)
1761
1746
1762
-
1763
1747
if (deletedFiles '= " " ){
1764
1748
set sc = ##class (SourceControl.Git.Utils ).RemoveFromServerSideSourceControl (deletedFiles )
1765
1749
}
@@ -1771,6 +1755,35 @@ ClassMethod SyncIrisWithRepoThroughCommand(ByRef outStream) As %Status
1771
1755
quit ##class (SourceControl.Git.PullEventHandler ).ForModifications (.files )
1772
1756
}
1773
1757
1758
+ ClassMethod ParseDiffStream (stream As %Stream .Object , verbose As %Boolean = 1 , Output files )
1759
+ {
1760
+ kill files
1761
+ while (stream .AtEnd = 0 ) {
1762
+ set file = stream .ReadLine ()
1763
+ set modification = ##class (SourceControl.Git.Modification ).%New ()
1764
+ set modification .changeType = $piece (file , $c (9 ), 1 )
1765
+
1766
+ set modification .externalName = $zstrip ($piece (file , $c (9 ), 2 )," <W" )
1767
+ if $extract (modification .changeType ) = " R" {
1768
+ set modification .changeType = " D"
1769
+ set modification .internalName = ##class (SourceControl.Git.Utils ).NameToInternalName (modification .externalName ,,0 )
1770
+ set files ($increment (files )) = modification
1771
+ set modification = ##class (SourceControl.Git.Modification ).%New ()
1772
+ set modification .changeType = " A"
1773
+ set modification .internalName = " "
1774
+ set modification .externalName = $zstrip ($piece (file , $c (9 ), 3 )," <W" )
1775
+ } elseif (modification .changeType '= " A" ){
1776
+ set modification .internalName = ##class (SourceControl.Git.Utils ).NameToInternalName (modification .externalName ,,0 )
1777
+ } else {
1778
+ set modification .internalName = " "
1779
+ }
1780
+ set files ($increment (files )) = modification
1781
+ if verbose {
1782
+ write !, " " , modification .changeType , " " , modification .internalName , " " , modification .externalName
1783
+ }
1784
+ }
1785
+ }
1786
+
1774
1787
ClassMethod SyncIrisWithRepoThroughDiff (ByRef files ) As %Status
1775
1788
{
1776
1789
set key = $order (files (" " ))
0 commit comments