Skip to content

Commit 74c4c31

Browse files
committed
issue resolved but still getting small MERGE_HEAD bug
1 parent 6f39ea8 commit 74c4c31

File tree

3 files changed

+72
-14
lines changed

3 files changed

+72
-14
lines changed

cls/SourceControl/Git/Util/Buffer.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,4 @@ Method UsePreviousDeviceAndSettings() [ Internal, Private ]
281281
}
282282

283283
}
284+

cls/SourceControl/Git/Utils.cls

Lines changed: 70 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,13 +1565,16 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
15651565

15661566
set newArgs($increment(newArgs)) = command
15671567

1568-
// defining variables for if statement use later
1569-
set syncIris = 0
1568+
set syncIrisWithDiff = 0 // whether IRIS needs to be synced with repo file changes using diff output
1569+
set syncIrisWithCommand = 0 // // whether IRIS needs to be synced with repo file changes using command output
15701570
set diffBase = ""
15711571
set diffCompare = ""
15721572
set pullOriginIndex = ""
1573-
if (command = "checkout") || (command = "merge") || (command = "rebase") || (command = "pull"){
1574-
set syncIris = 1
1573+
if (command = "checkout") || (command = "pull"){
1574+
set syncIrisWithDiff = 1
1575+
set diffCompare = args(args)
1576+
} elseif (command = "merge") || (command = "rebase") {
1577+
set syncIrisWithCommand = 1
15751578
set diffCompare = args(args)
15761579
}
15771580

@@ -1582,13 +1585,16 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
15821585
if newArgs(newArgs) = pullArg {
15831586
set pullOriginIndex = newArgs
15841587
}
1585-
if (args(i) = "checkout") || (args(i) = "merge") || (args(i) = "rebase") || (args(i) = "pull"){
1586-
set syncIris = 1
1588+
if (args(i) = "checkout") || (args(i) = "pull"){
1589+
set syncIrisWithDiff = 1
15871590
set diffCompare = args(i + 1)
15881591

15891592
if args = (i + 2) {
15901593
set diffBase = args(i + 2)
15911594
}
1595+
} elseif (args(i) = "merge") || (args(i) = "rebase"){
1596+
set syncIrisWithCommand = 1
1597+
set diffCompare = args(i + 1)
15921598
}
15931599

15941600
if (args(i) = "pull") {
@@ -1597,11 +1603,12 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
15971603
}
15981604
}
15991605

1600-
if (diffCompare = "--no-commit") || (diffCompare = "--abort") {
1601-
set syncIris = 0
1606+
if (diffCompare = "--no-commit") || (diffCompare = "--abort") || (diffCompare = "-b") {
1607+
set syncIrisWithDiff = 0
1608+
set syncIrisWithCommand = 0
16021609
}
16031610

1604-
if syncIris {
1611+
if syncIrisWithDiff {
16051612
if diffBase = "" {
16061613
set diffBase = ..GetCurrentBranch()
16071614
}
@@ -1621,7 +1628,6 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
16211628
set modification.internalName = ""
16221629
}
16231630
set files($increment(files)) = modification
1624-
set mod = files(files)
16251631
write !, ?4, modification.changeType, ?4, modification.internalName, ?4 , modification.externalName
16261632
}
16271633

@@ -1656,16 +1662,65 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
16561662
for stream=errStream,outStream {
16571663
set stream.RemoveOnClose = 1
16581664
}
1659-
do ..PrintStreams(errStream, outStream)
1660-
if syncIris {
1661-
$$$ThrowOnError(..SyncIrisWithRepo(.files))
1665+
// do ..PrintStreams(errStream, outStream)
1666+
if syncIrisWithDiff {
1667+
$$$ThrowOnError(..SyncIrisWithRepoThroughDiff(.files))
1668+
} elseif syncIrisWithCommand {
1669+
$$$ThrowOnError(..SyncIrisWithRepoThroughCommand(.outStream))
16621670
}
16631671
quit returnCode
16641672
}
16651673

1666-
ClassMethod SyncIrisWithRepo(ByRef files)
1674+
ClassMethod SyncIrisWithRepoThroughCommand(ByRef outStream) As %Status
16671675
{
1676+
set deletedFiles = ""
1677+
set addedFiles = ""
1678+
set files = ""
1679+
while (outStream.AtEnd = 0) {
1680+
1681+
set line = outStream.ReadLine()
1682+
set ^mtempz($i(^mtempz)) = line
1683+
set lineStart = $piece(line, " ", 2)
1684+
if (lineStart = "delete") || (lineStart = "create") {
1685+
set fileOperation = $select(lineStart = "create" : "A", 1: "D")
1686+
set externalName = $piece(line, " ", *)
1687+
set internalName = ##class(SourceControl.Git.Utils).NameToInternalName(externalName,,0)
1688+
set modification = ##class(SourceControl.Git.Modification).%New()
1689+
set modification.changeType = fileOperation
1690+
set modification.internalName = internalName
1691+
set modification.externalName = externalName
1692+
set files($i(files)) = modification
1693+
if fileOperation = "A" {
1694+
set addedFiles = addedFiles_","_internalName
1695+
} else {
1696+
set deletedFiles = deletedFiles_","_internalName
1697+
}
1698+
}
1699+
}
1700+
1701+
set deletedFiles = $extract(deletedFiles, 2, *)
1702+
set addedFiles = $extract(addedFiles, 2, *)
16681703

1704+
set ^mtemphw("addedFiles", $i(^mtemphw("addedFiles"))) = addedFiles
1705+
set ^mtemphw("deletedFiles", $i(^mtemphw("deletedFiles"))) = deletedFiles
1706+
1707+
if (deletedFiles '= ""){
1708+
set sc = ##class(SourceControl.Git.Utils).RemoveFromServerSideSourceControl(deletedFiles)
1709+
}
1710+
if (addedFiles '= ""){
1711+
set sc = ##class(SourceControl.Git.Utils).AddToServerSideSourceControl(addedFiles)
1712+
}
1713+
1714+
do outStream.Rewind()
1715+
set event = $classmethod(..PullEventClass(),"%New")
1716+
set event.LocalRoot = ..TempFolder()
1717+
merge event.ModifiedFiles = files
1718+
quit event.OnPull()
1719+
}
1720+
1721+
ClassMethod SyncIrisWithRepoThroughDiff(ByRef files) As %Status
1722+
{
1723+
set ^mtempz($i(^mtempz)) = "here"
16691724
set key = $order(files(""))
16701725
set deletedFiles = ""
16711726
set addedFiles = ""
@@ -2348,3 +2403,4 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status
23482403
}
23492404

23502405
}
2406+

cls/SourceControl/Git/WebUIDriver.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,4 @@ ClassMethod GetPackageVersion() As %Library.DynamicObject
243243
}
244244

245245
}
246+

0 commit comments

Comments
 (0)