Skip to content

Commit 0cb26a0

Browse files
committed
iris sync implemented
1 parent 5099279 commit 0cb26a0

File tree

1 file changed

+33
-43
lines changed

1 file changed

+33
-43
lines changed

cls/SourceControl/Git/Utils.cls

Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,29 +1605,53 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
16051605

16061606
set newArgs($increment(newArgs)) = command
16071607

1608-
1608+
// defining variables for if statement use later
1609+
set syncIris = 0
1610+
set diffBase = ""
16091611

16101612
if (command = "checkout") || (command = "merge") || (command = "rebase") {
16111613
set syncIris = 1
16121614
set diffCompare = args(args)
1613-
set diffBase = ""
16141615
}
16151616

1616-
1617+
16171618
for i=1:1:$get(args) {
16181619
if ($data(args(i))) {
16191620
set newArgs($increment(newArgs)) = args(i)
16201621
if (args(i) = "checkout") || (args(i) = "merge") || (args(i) = "rebase") {
16211622
set syncIris = 1
16221623
set diffCompare = args(i + 1)
1623-
set diffBase = ""
1624-
if $LISTLENGTH(args) = (i + 2) {
1624+
1625+
if args = (i + 2) {
16251626
set diffBase = args(i + 2)
16261627
}
16271628
}
16281629
}
16291630
}
16301631

1632+
if syncIris {
1633+
if diffBase = "" {
1634+
set diffBase = ..GetCurrentBranch()
1635+
}
1636+
do ##class(SourceControl.Git.Utils).RunGitCommandWithInput("diff",,.errorStream,.outputStream, diffBase_".."_diffCompare, "--name-status")
1637+
while (outputStream.AtEnd = 0) {
1638+
set file = outputStream.ReadLine()
1639+
set modification = ##class(SourceControl.Git.Modification).%New()
1640+
set modification.changeType = $piece(file, $c(9), 1)
1641+
1642+
set modification.externalName = $zstrip($piece(file, $c(9),2),"<W")
1643+
if (modification.changeType '= "A"){
1644+
set modification.internalName = ##class(SourceControl.Git.Utils).NameToInternalName(modification.externalName,,0)
1645+
}
1646+
else {
1647+
set modification.internalName = ""
1648+
}
1649+
set files($increment(files)) = modification
1650+
set mod = files(files)
1651+
write !, ?4, modification.changeType, ?4, modification.internalName, ?4 , modification.externalName
1652+
}
1653+
}
1654+
16311655
set outLog = ##class(%Library.File).TempFilename()
16321656
set errLog = ##class(%Library.File).TempFilename()
16331657

@@ -1656,49 +1680,14 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
16561680
}
16571681

16581682
if syncIris {
1659-
if diffBase = "" {
1660-
set diffBase = ..GetCurrentBranch()
1661-
}
1662-
do ..SyncIrisWithRepo(diffBase, diffCompare)
1683+
1684+
do ..SyncIrisWithRepo(.files)
16631685
}
16641686
quit returnCode
16651687
}
16661688

1667-
ClassMethod SyncIrisWithRepo(diffBase As %String, diffCompare As %String)
1689+
ClassMethod SyncIrisWithRepo(ByRef files)
16681690
{
1669-
do ##class(SourceControl.Git.Utils).RunGitCommandWithInput("diff",,.errStream,.outStream, diffBase_".."_diffCompare, "--name-status")
1670-
while (outStream.AtEnd = 0) {
1671-
set file = outStream.ReadLine()
1672-
set modification = ##class(SourceControl.Git.Modification).%New()
1673-
set modification.changeType = $piece(file, $c(9), 1)
1674-
set modification.externalName = $zstrip($piece(file, $c(9),2),"<W")
1675-
if (modification.changeType '= "A"){
1676-
set modification.internalName = ##class(SourceControl.Git.Utils).NameToInternalName(modification.externalName,,0)
1677-
}
1678-
else {
1679-
set modification.internalName = ""
1680-
}
1681-
set files($increment(files)) = modification
1682-
write !, ?4, modification.changeType, ?4, modification.internalName, ?4 , modification.externalName
1683-
}
1684-
if ('$data(files)) {
1685-
write !, ?4, "None"
1686-
if preview {
1687-
quit $$$OK
1688-
}
1689-
write !, "Already up to date."
1690-
quit $$$OK
1691-
} elseif preview {
1692-
quit $$$OK
1693-
}
1694-
1695-
set sc = ..RunGitWithArgs(.errStream, .outStream, "pull", remote, branchName)
1696-
if (sc=1){
1697-
do ..PrintStreams(errStream, outStream)
1698-
quit $$$ERROR(5001, "Pull event handler not called. Fix errors before compiling.")
1699-
}
1700-
do ..PrintStreams(outStream)
1701-
write !
17021691

17031692
set key = $order(files(""))
17041693
set deletedFiles = ""
@@ -1714,6 +1703,7 @@ ClassMethod SyncIrisWithRepo(diffBase As %String, diffCompare As %String)
17141703
if (modification.internalName '= "") {
17151704
set addedFiles = addedFiles_","_modification.internalName
17161705
set files(key) = modification
1706+
17171707
}
17181708
}
17191709
set key = $order(files(key))

0 commit comments

Comments
 (0)