Skip to content

Commit 23b9470

Browse files
When performing a pull, sync IRIS with repository changes using diff output rather than command output
1 parent 03a52c2 commit 23b9470

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

cls/SourceControl/Git/Utils.cls

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,11 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
17371737
} elseif (command = "restore") {
17381738
// Leave diffCompare empty, this actually does the right thing.
17391739
set syncIrisWithDiff = 1
1740-
} elseif (command = "merge") || (command = "rebase") || (command = "pull") {
1740+
} elseif (command = "pull") {
1741+
set syncIrisWithDiff = 1
1742+
// The current revision, prior to the pull, will be compared against
1743+
set diffCompare = ..GetCurrentRevision()
1744+
} elseif (command = "merge") || (command = "rebase") {
17411745
set syncIrisWithCommand = 1
17421746
if $data(args) && $data(args(args),diffCompare) {
17431747
// no-op
@@ -1801,7 +1805,10 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
18011805
set syncIrisWithCommand = 0
18021806
}
18031807

1804-
if syncIrisWithDiff {
1808+
// If performing a pull don't perform a diff until after the pull has occured.
1809+
// This is to avoid a double fetch, as pull performs one for us and also to avoid a potential
1810+
// race condition if the remote changes between now and the pull actually being performed.
1811+
if syncIrisWithDiff && (command '= "pull") {
18051812
if diffBase = "" {
18061813
set diffBase = ..GetCurrentBranch()
18071814
}
@@ -1832,6 +1839,13 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
18321839
}
18331840
}
18341841

1842+
// If performing a pull then do a diff now after the pull has occured.
1843+
if syncIrisWithDiff && (command = "pull") {
1844+
do ##class(SourceControl.Git.Utils).RunGitCommandWithInput("diff",,.errorStream,.outputStream, diffCompare, "--name-status")
1845+
// Verbose output should not be required as pull already outputs a summary
1846+
do ..ParseDiffStream(outputStream,0,.files)
1847+
}
1848+
18351849
set errStream = ##class(%Stream.FileCharacter).%OpenId(errLog,,.sc)
18361850
set outStream = ##class(%Stream.FileCharacter).%OpenId(outLog,,.sc)
18371851
set outStream.TranslateTable="UTF8"

0 commit comments

Comments
 (0)