Skip to content

Commit 2f47a5e

Browse files
authored
Merge pull request #320 from intersystems/pullEventHandlerDeletion
Handle file deletion in incremental load PullEventHandler and throw errors (if any) instead of returning Success Status
2 parents fefdb03 + 83e71bc commit 2f47a5e

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- Performance improvements (#269, #315)
1717
- Checkout of branches whose names contain slashes via Web UI no longer fails (#295)
1818
- Display other developer's username in Web UI's Workspace when hovering over the name of a file they changed (#304)
19+
- Incremental load PullEventHandler now handles file deletion (#299)
20+
- Incremental load PullEventHandler no longer returns a Success Status if an error was thrown during the pull process (#300)
1921

2022
## [2.3.0] - 2023-12-06
2123

cls/SourceControl/Git/Extension.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ Method OnBeforeDelete(InternalName As %String) As %Status
275275
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(InternalName)
276276
set InternalName = ##class(Utils).NormalizeInternalName(InternalName)
277277
set Filename = ##class(Utils).FullExternalName(InternalName)
278-
if ##class(Utils).IsInSourceControl(InternalName) {
278+
if ##class(Utils).IsInSourceControl(InternalName) && ##class(%File).Exists(Filename) {
279279
quit ##class(Change).AddDeletedToUncommitted(Filename, InternalName)
280280
}
281281
quit $$$OK

cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@ Method OnPull() As %Status
1616
set internalName = ..ModifiedFiles(i).internalName
1717
if ((internalName = "") && (..ModifiedFiles(i).changeType '= "D")) {
1818
write !, ..ModifiedFiles(i).externalName, " was not imported into the database and will not be compiled. "
19+
} elseif (..ModifiedFiles(i).changeType = "D") {
20+
set sc = ..DeleteFile(internalName)
21+
if sc {
22+
write !, ..ModifiedFiles(i).externalName, " was deleted."
23+
} else {
24+
write !, "WARNING: Deletion of ", ..ModifiedFiles(i).externalName, " failed."
25+
}
1926
} else {
2027
set compilelist(internalName) = ""
2128
set nFiles = nFiles + 1
2229
set loadSC = $$$ADDSC(loadSC,##class(SourceControl.Git.Utils).ImportItem(internalName, 1))
30+
$$$ThrowOnError(loadSC)
2331
}
2432
}
2533

@@ -30,5 +38,16 @@ Method OnPull() As %Status
3038
quit $system.OBJ.CompileList(.compilelist, "cukb")
3139
}
3240

41+
Method DeleteFile(item As %String)
42+
{
43+
set type = ##class(SourceControl.Git.Utils).Type(item)
44+
if (type = "cls") {
45+
quit $System.OBJ.Delete(item)
46+
} elseif (type = "csp") {
47+
quit $System.CSP.DeletePage(item)
48+
} else {
49+
quit ##class(%Library.RoutineMgr).Delete(item)
50+
}
3351
}
3452

53+
}

cls/SourceControl/Git/Utils.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ ClassMethod Pull(remote As %String = "origin", preview As %Boolean = 0) As %Stat
355355
write !, "Fetch done"
356356
write !, "Files that will be modified by git pull: "
357357

358-
do ##class(SourceControl.Git.Utils).RunGitCommandWithInput("diff",,.errStream,.outStream, (branchName_"..."_(remote_"/"_branchName)), "--name-status")
358+
do ##class(SourceControl.Git.Utils).RunGitCommandWithInput("diff",,.errStream,.outStream, remote_"/"_branchName, "--name-status")
359359
while (outStream.AtEnd = 0) {
360360
set file = outStream.ReadLine()
361361
set modification = ##class(SourceControl.Git.Modification).%New()

0 commit comments

Comments
 (0)