From 6a5be67f50b79dcbade26a6d94391ac638d02f82 Mon Sep 17 00:00:00 2001 From: Pravin Barton <9560941+isc-pbarton@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:59:23 -0400 Subject: [PATCH 1/5] compile items on import --- CHANGELOG.md | 2 ++ cls/SourceControl/Git/Utils.cls | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc070595..d0859463 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added a new "Branch" parameter to `##class(SourceControl.Git.PullEventHandler)` (#351) - Command-line utility to do a baseline export of items in a namespace +### Fixed +- Import All options now compile items after they are imported into IRIS from the repository (#362) ## [2.3.1] - 2024-04-30 diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index 196f1e71..3b6d6c59 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -1230,7 +1230,7 @@ ClassMethod ImportItem(InternalName As %String, force As %Boolean = 0, verbose A if ($extract(InternalName, 1) = "/"){ set sc = ..ImportCSPFile(InternalName) } else{ - set sc = $system.OBJ.Load(filename,"-l-d") + set sc = $system.OBJ.Load(filename,"ck") } } if sc { @@ -2282,4 +2282,3 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status } } - From 9718793d526c27d7250314752e07f1b97054cd43 Mon Sep 17 00:00:00 2001 From: Pravin Barton <9560941+isc-pbarton@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:59:23 -0400 Subject: [PATCH 2/5] compile items on import --- CHANGELOG.md | 1 + cls/SourceControl/Git/Utils.cls | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dbba46d..f2e0fda6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Modifications to local repo files are now synced with IRIS (#153) - Menu items names are properly translated from internal name in VSCode, Management Portal (#372) +- Import All options now compile items after they are imported into IRIS from the repository (#362) ## [2.3.1] - 2024-04-30 diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index b209ba6c..d9a1cf46 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -1187,7 +1187,7 @@ ClassMethod ImportItem(InternalName As %String, force As %Boolean = 0, verbose A if ($extract(InternalName, 1) = "/"){ set sc = ..ImportCSPFile(InternalName) } else{ - set sc = $system.OBJ.Load(filename,"-l-d") + set sc = $system.OBJ.Load(filename,"ck") } } if sc { From 31ea12b182a46884df620b363417febba86800e2 Mon Sep 17 00:00:00 2001 From: Pravin Barton <9560941+isc-pbarton@users.noreply.github.com> Date: Wed, 26 Jun 2024 09:23:44 -0400 Subject: [PATCH 3/5] Revert "compile items on import" This reverts commit 9718793d526c27d7250314752e07f1b97054cd43. --- CHANGELOG.md | 1 - cls/SourceControl/Git/Utils.cls | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2e0fda6..1dbba46d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Modifications to local repo files are now synced with IRIS (#153) - Menu items names are properly translated from internal name in VSCode, Management Portal (#372) -- Import All options now compile items after they are imported into IRIS from the repository (#362) ## [2.3.1] - 2024-04-30 diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index d9a1cf46..b209ba6c 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -1187,7 +1187,7 @@ ClassMethod ImportItem(InternalName As %String, force As %Boolean = 0, verbose A if ($extract(InternalName, 1) = "/"){ set sc = ..ImportCSPFile(InternalName) } else{ - set sc = $system.OBJ.Load(filename,"ck") + set sc = $system.OBJ.Load(filename,"-l-d") } } if sc { From 4d023192dc3a9ff54c42465c7e72bda95749a5cc Mon Sep 17 00:00:00 2001 From: Pravin Barton <9560941+isc-pbarton@users.noreply.github.com> Date: Wed, 26 Jun 2024 17:09:42 -0400 Subject: [PATCH 4/5] compile on import using pull event handler --- CHANGELOG.md | 1 + cls/SourceControl/Git/Settings.cls | 5 ++++- cls/SourceControl/Git/Utils.cls | 24 ++++++++++++++++++++++++ csp/gitprojectsettings.csp | 12 ++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dbba46d..40dc0d5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Command-line utility to do a baseline export of items in a namespace - 'New Branch' menu option in basic now will create new branches from the configured default merge branch (#366) - Merging back with the default merge branch is now a part of the basic mode's Sync flow (#366) +- Added a new option "compileOnImport". If true, Import options will compile files using the pull event handler. (#362) ### Fixed - Modifications to local repo files are now synced with IRIS (#153) diff --git a/cls/SourceControl/Git/Settings.cls b/cls/SourceControl/Git/Settings.cls index 3ac96028..dc73319f 100644 --- a/cls/SourceControl/Git/Settings.cls +++ b/cls/SourceControl/Git/Settings.cls @@ -44,6 +44,9 @@ Property systemBasicMode As %Boolean [ InitialExpression = {##class(SourceContro /// In Basic mode, Sync will merge changes from this remote branch Property defaultMergeBranch As %String [ InitialExpression = {##class(SourceControl.Git.Utils).DefaultMergeBranch()} ]; +/// Import All options compile imported options using the configured pull event handler +Property compileOnImport As %Boolean [ InitialExpression = {##class(SourceControl.Git.Utils).CompileOnImport()} ]; + Property Mappings [ MultiDimensional ]; Method %OnNew() As %Status @@ -97,6 +100,7 @@ Method %Save() As %Status set @storage@("settings","settingsUIReadOnly") = ..settingsUIReadOnly set @storage@("settings", "mappedItemsReadOnly") = ..mappedItemsReadOnly set @storage@("settings", "defaultMergeBranch") = ..defaultMergeBranch + set @storage@("settings", "compileOnImport") = ..compileOnImport set @storage@("settings", "basicMode") = ..systemBasicMode if ..basicMode = "system" { kill @storage@("settings", "user", $username, "basicMode") @@ -206,4 +210,3 @@ Method OnAfterConfigure() As %Boolean } } - diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index b209ba6c..a3ebcc01 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -153,6 +153,11 @@ ClassMethod PrivateKeyFile() As %String quit $get(@..#Storage@("settings","ssh","privateKeyFile")) } +ClassMethod CompileOnImport() As %Boolean +{ + quit $get(@..#Storage@("settings","compileOnImport"),1) +} + ClassMethod NeedSettings() As %Boolean [ CodeMode = expression ] { (..TempFolder() = "") || (..GitBinPath() = "") || (..GitBinPath() = """") @@ -1294,13 +1299,17 @@ ClassMethod ImportRoutines(force As %Boolean = 0) As %Status #dim ec as %Status = ..ListItemsInFiles(.itemList, .err) quit:'ec ec + + kill files + set settings = ##class(SourceControl.Git.Settings).%New() #dim internalName as %String = "" for { set internalName = $order(itemList(internalName)) quit:internalName="" set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(internalName) continue:context.Package'=refPackage + set doImport = ..IsRoutineOutdated(internalName) || force if ..IsInSourceControl(internalName) { set sc = ..ImportItem(internalName, force) } else { @@ -1309,6 +1318,21 @@ ClassMethod ImportRoutines(force As %Boolean = 0) As %Status if $$$ISERR(sc) { set ec = $$$ADDSC(ec, sc) } + if doImport && settings.compileOnImport { + set modification = ##class(SourceControl.Git.Modification).%New() + set modification.changeType = "M" + set modification.internalName = internalName + set modification.externalName = ..FullExternalName(internalName) + set files($increment(files)) = modification + } + } + + set eventHandler = $classmethod(..PullEventClass(),"%New") + set eventHandler.LocalRoot = ..TempFolder() + merge eventHandler.ModifiedFiles = files + set sc = eventHandler.OnPull() + if $$$ISERR(sc) { + set ec = $$$ADDSC(ec,sc) } //let's delete all items for which corresponding files had been deleted diff --git a/csp/gitprojectsettings.csp b/csp/gitprojectsettings.csp index 50e91655..0aed2f5e 100644 --- a/csp/gitprojectsettings.csp +++ b/csp/gitprojectsettings.csp @@ -90,6 +90,8 @@ body { set settings.mappedItemsReadOnly = 0 } + set settings.compileOnImport = ($Get(%request.Data("compileOnImport", 1)) = 1) + if ($Get(%request.Data("basicMode", 1)) = 1) { set settings.basicMode = 1 } elseif ($Get(%request.Data("basicMode", 1)) = "system"){ @@ -336,6 +338,16 @@ body { +
+ +
+
+ + +
+
+
From f7f2be65414568de33187a8ed94cfc0e725073ca Mon Sep 17 00:00:00 2001 From: Pravin Barton <9560941+isc-pbarton@users.noreply.github.com> Date: Wed, 26 Jun 2024 17:27:51 -0400 Subject: [PATCH 5/5] refactor deletes on import into pull event handler --- .../Git/PullEventHandler/IncrementalLoad.cls | 33 +++++++++--- cls/SourceControl/Git/Utils.cls | 51 +++++-------------- 2 files changed, 38 insertions(+), 46 deletions(-) diff --git a/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls b/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls index ab608165..da34b62d 100644 --- a/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls +++ b/cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls @@ -38,17 +38,36 @@ Method OnPull() As %Status quit $system.OBJ.CompileList(.compilelist, "cukb") } -Method DeleteFile(item As %String) +Method DeleteFile(item As %String) As %Status { + set sc = $$$OK set type = ##class(SourceControl.Git.Utils).Type(item) - if (type = "cls") { - quit $System.OBJ.Delete(item) - } elseif (type = "csp") { - quit $System.CSP.DeletePage(item) + set name = ##class(SourceControl.Git.Utils).NameWithoutExtension(item) + set deleted = 1 + if type = "prj" { + set sc = $system.OBJ.DeleteProject(name) + }elseif type = "cls" { + set sc = $system.OBJ.Delete(item) + }elseif $listfind($listbuild("mac","int","inc","bas","mvb","mvi"), type) > 0 { + set sc = ##class(%Routine).Delete(item) + }elseif type = "csp" { + set sc = $System.CSP.DeletePage(item) + }elseif ##class(SourceControl.Git.Utils).UserTypeCached(item) { + set sc = ##class(%Library.RoutineMgr).Delete(item) } else { - quit ##class(%Library.RoutineMgr).Delete(item) + set deleted = 0 } + + if deleted && $$$ISOK(sc) { + do ##class(SourceControl.Git.Utils).RemoveRoutineTSH(item) + kill $$$TrackedItems(##class(SourceControl.Git.Utils).NormalizeExtension(item)) + } else { + if +$system.Status.GetErrorCodes(sc) = $$$ClassDoesNotExist { + // if something we wanted to delete is already deleted -- good! + set sc = $$$OK + } + } + return sc } } - diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index a3ebcc01..ab0d630b 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -1327,13 +1327,6 @@ ClassMethod ImportRoutines(force As %Boolean = 0) As %Status } } - set eventHandler = $classmethod(..PullEventClass(),"%New") - set eventHandler.LocalRoot = ..TempFolder() - merge eventHandler.ModifiedFiles = files - set sc = eventHandler.OnPull() - if $$$ISERR(sc) { - set ec = $$$ADDSC(ec,sc) - } //let's delete all items for which corresponding files had been deleted #dim item as %String = "" @@ -1347,41 +1340,21 @@ ClassMethod ImportRoutines(force As %Boolean = 0) As %Status set fullExternalName = ..FullExternalName(item) if '##class(%File).Exists(fullExternalName) { write !,fullExternalName," does not exist - deleting ",item - #dim type as %String = ..Type(item) - #dim name as %String = ..NameWithoutExtension(item) - #dim deleted as %Boolean = 1 - if type = "prj" { - set ec = $$$ADDSC(ec, $system.OBJ.DeleteProject(name)) - }elseif type = "cls" { - set ec = $$$ADDSC(ec, $system.OBJ.Delete(item)) - }elseif $listfind($listbuild("mac","int","inc","bas","mvb","mvi"), type) > 0 { - set ec = $$$ADDSC(ec, ##class(%Routine).Delete(item)) - }elseif type = "csp" { - #dim filename = $system.CSP.GetFileName(item) - if ##class(%File).Exists(filename) && '##class(%File).Delete(filename) { - set ec = $$$ADDSC(ec, ..MakeError("Error while removing "_item)) - } - }elseif ..UserTypeCached(item) { - set ec = $$$ADDSC(ec, ##class(%Library.RoutineMgr).Delete(item)) - } else { - set deleted = 0 - } - - if deleted && ec { - do ..RemoveRoutineTSH(item) - kill $$$TrackedItems(..NormalizeExtension(item)) - write !, item, " was deleted" - } else { - if +$system.Status.GetErrorCodes(ec) '= $$$ClassDoesNotExist { - write !, "Error: could not delete ", item - } else { - // if something we wanted to delete is already deleted -- good! - set ec = $$$OK - } - } + set modification = ##class(SourceControl.Git.Modification).%New() + set modification.changeType = "D" + set modification.internalName = item + set modification.externalName = fullExternalName + set files($increment(files)) = modification } } + set eventHandler = $classmethod(..PullEventClass(),"%New") + set eventHandler.LocalRoot = ..TempFolder() + merge eventHandler.ModifiedFiles = files + set sc = eventHandler.OnPull() + if $$$ISERR(sc) { + set ec = $$$ADDSC(ec,sc) + } write !, "==import done==" quit ec }