From 9a8406c3986beb0c8be2b1497eae5666fa42a406 Mon Sep 17 00:00:00 2001 From: isc-vgao Date: Thu, 11 Jan 2024 15:41:06 -0500 Subject: [PATCH 1/7] add file to test delete and pull --- cls/SourceControl/Git/TestDelete.cls | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 cls/SourceControl/Git/TestDelete.cls diff --git a/cls/SourceControl/Git/TestDelete.cls b/cls/SourceControl/Git/TestDelete.cls new file mode 100644 index 00000000..beb39395 --- /dev/null +++ b/cls/SourceControl/Git/TestDelete.cls @@ -0,0 +1,4 @@ +Class SourceControl.Git.TestDelete Extends %RegisteredObject +{ + +} From 83cda4b775b0539445094a386d9055cd61dd1273 Mon Sep 17 00:00:00 2001 From: isc-vgao Date: Wed, 24 Jan 2024 17:13:11 -0500 Subject: [PATCH 2/7] handle deletion in incremental load PullEventHandler --- CHANGELOG.md | 2 ++ cls/SourceControl/Git/Extension.cls | 2 +- cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls | 3 ++- cls/SourceControl/Git/TestDelete.cls | 4 ---- cls/SourceControl/Git/Utils.cls | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) delete mode 100644 cls/SourceControl/Git/TestDelete.cls diff --git a/CHANGELOG.md b/CHANGELOG.md index 3550acfa..429b5efb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/cls/SourceControl/Git/Extension.cls b/cls/SourceControl/Git/Extension.cls index 96785da2..3f34fb79 100644 --- a/cls/SourceControl/Git/Extension.cls +++ b/cls/SourceControl/Git/Extension.cls @@ -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 diff --git a/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls b/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls index f6a51896..42483736 100644 --- a/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls +++ b/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls @@ -14,12 +14,13 @@ Method OnPull() As %Status for i=1:1:$get(..ModifiedFiles){ set internalName = ..ModifiedFiles(i).internalName - if ((internalName = "") && (..ModifiedFiles(i).changeType '= "D")) { + if (((internalName = "") && (..ModifiedFiles(i).changeType '= "D")) || (..ModifiedFiles(i).changeType = "D")) { write !, ..ModifiedFiles(i).externalName, " was not imported into the database and will not be compiled. " } else { set compilelist(internalName) = "" set nFiles = nFiles + 1 set loadSC = $$$ADDSC(loadSC,##class(SourceControl.Git.Utils).ImportItem(internalName, 1)) + $$$ThrowOnError(loadSC) } } diff --git a/cls/SourceControl/Git/TestDelete.cls b/cls/SourceControl/Git/TestDelete.cls deleted file mode 100644 index beb39395..00000000 --- a/cls/SourceControl/Git/TestDelete.cls +++ /dev/null @@ -1,4 +0,0 @@ -Class SourceControl.Git.TestDelete Extends %RegisteredObject -{ - -} diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index f41960cc..933d5bcb 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -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() From 3cff66c48531de44d2aeca3215d7e658f2d3e914 Mon Sep 17 00:00:00 2001 From: isc-vgao Date: Thu, 25 Jan 2024 16:08:01 -0500 Subject: [PATCH 3/7] delete item from database --- .../Git/PullEventHandler/IncrementalLoad.cls | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls b/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls index 42483736..7f6d86c2 100644 --- a/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls +++ b/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls @@ -14,8 +14,11 @@ Method OnPull() As %Status for i=1:1:$get(..ModifiedFiles){ set internalName = ..ModifiedFiles(i).internalName - if (((internalName = "") && (..ModifiedFiles(i).changeType '= "D")) || (..ModifiedFiles(i).changeType = "D")) { + 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") { + $$$ThrowOnError(..DeleteFile(internalName)) + write !, ..ModifiedFiles(i).externalName, " was deleted." } else { set compilelist(internalName) = "" set nFiles = nFiles + 1 @@ -31,5 +34,17 @@ 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") { + do $System.OBJ.Delete(item) + } elseif (type = "csp") { + do $System.CSP.DeletePage(item) + } else { + do ##class(%Library.RoutineMgr).Delete(item) + } + Quit $$$OK } +} From ae3fb03bf4a1fee5aedfcbd1422f91be209c809e Mon Sep 17 00:00:00 2001 From: isc-vgao Date: Fri, 26 Jan 2024 09:57:12 -0500 Subject: [PATCH 4/7] handle error with different print statement --- .../Git/PullEventHandler/IncrementalLoad.cls | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls b/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls index 7f6d86c2..6f568534 100644 --- a/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls +++ b/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls @@ -17,8 +17,12 @@ Method OnPull() As %Status 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") { - $$$ThrowOnError(..DeleteFile(internalName)) - write !, ..ModifiedFiles(i).externalName, " was deleted." + set sc = ..DeleteFile(internalName) + if sc { + write !, ..ModifiedFiles(i).externalName, " was deleted." + } else { + write !, "Deletion of ", ..ModifiedFiles(i).externalName, " failed." + } } else { set compilelist(internalName) = "" set nFiles = nFiles + 1 @@ -38,13 +42,12 @@ Method DeleteFile(item As %String) { set type = ##class(SourceControl.Git.Utils).Type(item) if (type = "cls") { - do $System.OBJ.Delete(item) + quit $System.OBJ.Delete(item) } elseif (type = "csp") { - do $System.CSP.DeletePage(item) + quit $System.CSP.DeletePage(item) } else { - do ##class(%Library.RoutineMgr).Delete(item) + quit ##class(%Library.RoutineMgr).Delete(item) } - Quit $$$OK } } From 83e71bca17c3e2dd5c3adf5135e614a07ad14a68 Mon Sep 17 00:00:00 2001 From: isc-vgao Date: Fri, 26 Jan 2024 10:22:11 -0500 Subject: [PATCH 5/7] add WARNING to print statement --- cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls b/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls index 6f568534..de052822 100644 --- a/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls +++ b/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls @@ -21,7 +21,7 @@ Method OnPull() As %Status if sc { write !, ..ModifiedFiles(i).externalName, " was deleted." } else { - write !, "Deletion of ", ..ModifiedFiles(i).externalName, " failed." + write !, "WARNING: Deletion of ", ..ModifiedFiles(i).externalName, " failed." } } else { set compilelist(internalName) = "" From 91600ebbc794c0e647843428fd8c1d6878064faf Mon Sep 17 00:00:00 2001 From: isc-vgao Date: Fri, 26 Jan 2024 11:44:56 -0500 Subject: [PATCH 6/7] fix for git add CSP application --- cls/SourceControl/Git/Utils.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index 933d5bcb..ce66781d 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -985,7 +985,7 @@ ClassMethod NormalizeInternalName(ByRef name As %String) As %String set type = ..Type(.name) - if $extract(name) '= "/" { + if ($extract(name) '= "/") && (type'="csp") { quit $piece(name,".",1,*-1)_"."_$zconvert($piece(name,".",*),"U") } From 9dbba429d5b783ee690e0a4540b6d448383b70bc Mon Sep 17 00:00:00 2001 From: isc-vgao Date: Fri, 26 Jan 2024 11:47:11 -0500 Subject: [PATCH 7/7] append git add csp application fix to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 429b5efb..3154b6eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - 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) +- CSP applications can now be added to Git successfully (#308) ## [2.3.0] - 2023-12-06