Skip to content

Handle file deletion in incremental load PullEventHandler and throw errors (if any) instead of returning Success Status #320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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

## [2.3.0] - 2023-12-06

Expand Down
2 changes: 1 addition & 1 deletion cls/SourceControl/Git/Extension.cls
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ Method OnBeforeDelete(InternalName As %String) As %Status
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(InternalName)
set InternalName = ##class(Utils).NormalizeInternalName(InternalName)
set Filename = ##class(Utils).FullExternalName(InternalName)
if ##class(Utils).IsInSourceControl(InternalName) {
if ##class(Utils).IsInSourceControl(InternalName) && ##class(%File).Exists(Filename) {
quit ##class(Change).AddDeletedToUncommitted(Filename, InternalName)
}
quit $$$OK
Expand Down
19 changes: 19 additions & 0 deletions cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@ Method OnPull() As %Status
set internalName = ..ModifiedFiles(i).internalName
if ((internalName = "") && (..ModifiedFiles(i).changeType '= "D")) {
write !, ..ModifiedFiles(i).externalName, " was not imported into the database and will not be compiled. "
} elseif (..ModifiedFiles(i).changeType = "D") {
set sc = ..DeleteFile(internalName)
if sc {
write !, ..ModifiedFiles(i).externalName, " was deleted."
} else {
write !, "WARNING: Deletion of ", ..ModifiedFiles(i).externalName, " failed."
}
} else {
set compilelist(internalName) = ""
set nFiles = nFiles + 1
set loadSC = $$$ADDSC(loadSC,##class(SourceControl.Git.Utils).ImportItem(internalName, 1))
$$$ThrowOnError(loadSC)
}
}

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

Method DeleteFile(item As %String)
{
set type = ##class(SourceControl.Git.Utils).Type(item)
if (type = "cls") {
quit $System.OBJ.Delete(item)
} elseif (type = "csp") {
quit $System.CSP.DeletePage(item)
} else {
quit ##class(%Library.RoutineMgr).Delete(item)
}
}

}
2 changes: 1 addition & 1 deletion cls/SourceControl/Git/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ ClassMethod Pull(remote As %String = "origin", preview As %Boolean = 0) As %Stat
write !, "Fetch done"
write !, "Files that will be modified by git pull: "

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