From 2c5bc8e9eedfd6ef5bf9ac601bf14996e14a944a Mon Sep 17 00:00:00 2001 From: Pravin Barton <9560941+isc-pbarton@users.noreply.github.com> Date: Mon, 18 Aug 2025 17:03:44 -0400 Subject: [PATCH] fix: import all now properly imports CSP files --- CHANGELOG.md | 1 + .../Git/PackageManagerContext.cls | 10 ++-- cls/SourceControl/Git/Utils.cls | 16 ++++-- test/UnitTest/SourceControl/Git/ImportAll.cls | 51 ++++++++++++++----- 4 files changed, 56 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1b329f0..febd200b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix "Export All" stopping prematurely because a tracked item no longer exist in the namespace (#821) - Import All now outputs a warning instead of an error when an item is in the wrong path (#291) - Fixed an error where classes with compilation errors would revert to broken versions on export (#830) +- Fixed Import All deploying changes to files in a CSP application (#828) - Fixed installation of the package on IRIS versions with the IRISSECURITY database (#770) ## [2.12.2] - 2025-07-08 diff --git a/cls/SourceControl/Git/PackageManagerContext.cls b/cls/SourceControl/Git/PackageManagerContext.cls index 103f4722..9438a47b 100644 --- a/cls/SourceControl/Git/PackageManagerContext.cls +++ b/cls/SourceControl/Git/PackageManagerContext.cls @@ -18,16 +18,16 @@ Method InternalNameSet(InternalName As %String = "") As %Status set InternalName = ##class(SourceControl.Git.Utils).NormalizeInternalName(InternalName) if (InternalName '= i%InternalName) { set i%InternalName = InternalName + set resourceReference = $$$NULLOREF if (InternalName = ##class(SourceControl.Git.Settings.Document).#INTERNALNAME) { - // git source control settings document is never in an IPM context - quit $$$OK - } - if $$$comClassDefined("%IPM.ExtensionBase.Utils") { + // Embedded Git settings document is never in an IPM context + set ..Package = $$$NULLOREF + } elseif $$$comClassDefined("%IPM.ExtensionBase.Utils") { set ..Package = ##class(%IPM.ExtensionBase.Utils).FindHomeModule(InternalName,,.resourceReference) } elseif $$$comClassDefined("%ZPM.PackageManager.Developer.Extension.Utils") { set ..Package = ##class(%ZPM.PackageManager.Developer.Extension.Utils).FindHomeModule(InternalName,,.resourceReference) } else { - quit $$$OK + set ..Package = $$$NULLOREF } set ..ResourceReference = resourceReference set ..IsInGitEnabledPackage = $isobject(..Package) && ##class(%Library.File).Exists(##class(%Library.File).NormalizeFilename(".git",..Package.Root)) diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index 252222c9..1ff0b905 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -1468,8 +1468,8 @@ ClassMethod ImportCSPFile(InternalName As %String) As %Status Quit $$$OK } // Delete original if exists, otherwise create new file - if '(##class(%File).CopyFile(srcFile, cspFile, 1)) { - set sc = $$$ERROR($$$GeneralError, "Unable to import '"_srcFile_"'") + if '(##class(%File).CopyFile(srcFile, cspFile, 1, .ret)) { + set sc = $$$ERROR($$$GeneralError,"Unable to copy CSP file from "_srcFile_" to "_cspFile_": return code "_ret) } Quit sc @@ -1486,8 +1486,12 @@ ClassMethod ListItemsRecursively(type, fileSpec, directory, ByRef itemList) [ Pr set internalName = files.ItemName if ($zconvert(type,"l") = "ptd") { do ##class(SourceControl.Git.Production).ParseExternalName($translate(files.Name,"\","/"), .internalName) + } else { + set internalName = ..NameToInternalName(files.Name,,0) + } + if (internalName '= "") { + set itemList(internalName) = "" } - set itemList(internalName) = "" } } } @@ -1515,7 +1519,9 @@ ClassMethod ListItemsInFiles(ByRef itemList, ByRef err) As %Status set mappedFilePath = ##class(%File).NormalizeFilename(mappedRelativePath, ..TempFolder()) if (##class(%File).DirectoryExists(mappedFilePath)){ - if ..UserTypeCached("foo."_mappingFileType, .userTypeClass) { + if (mappingFileType = "/CSP/") { + do ..ListItemsRecursively(mappingFileType,"*",mappedFilePath,.itemList) + } elseif ..UserTypeCached("foo."_mappingFileType, .userTypeClass) { set fileSpec = $select( userTypeClass="Ens.Util.ProjectTextDocument": "*.xml;*.XML", 1: "*."_$zcvt(mappingFileType,"L")_";*."_$zconvert(mappingFileType,"U")) @@ -1599,7 +1605,7 @@ ClassMethod ImportRoutines(force As %Boolean = 0, pullEventClass As %String) As set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(internalName) continue:context.Package'=refPackage - set doImport = ..IsRoutineOutdated(internalName) || force + set doImport = force || ..IsRoutineOutdated(internalName) if '..IsInSourceControl(internalName) { set sc = ..AddToServerSideSourceControl(internalName) if $$$ISERR(sc) { diff --git a/test/UnitTest/SourceControl/Git/ImportAll.cls b/test/UnitTest/SourceControl/Git/ImportAll.cls index 7164614c..cf67f3b1 100644 --- a/test/UnitTest/SourceControl/Git/ImportAll.cls +++ b/test/UnitTest/SourceControl/Git/ImportAll.cls @@ -1,28 +1,51 @@ -Class UnitTest.SourceControl.Git.ImportAll Extends %UnitTest.TestCase +Class UnitTest.SourceControl.Git.ImportAll Extends UnitTest.SourceControl.Git.AbstractTest { -Property InitialExtension As %String [ InitialExpression = {##class(%Studio.SourceControl.Interface).SourceControlClassGet()} ]; - -Property SourceControlGlobal [ MultiDimensional ]; +Property WebAppPath As %String; Method %OnNew(initvalue) As %Status { - Merge ..SourceControlGlobal = ^SYS("SourceControl") + $$$QuitOnError(##super(initvalue)) Kill ^SYS("SourceControl") + /// add mappings for MAC and CSP Set settings = ##class(SourceControl.Git.Settings).%New() - Set settings.namespaceTemp = ##class(%Library.File).TempFilename()_"dir" Set settings.Mappings("MAC","*")="rtn/" + Set settings.Mappings("/CSP/","/csp/git/unittest/xsl")="csp/git/unittest/xsl" $$$ThrowOnError(settings.%Save()) - Do ##class(%Studio.SourceControl.Interface).SourceControlClassSet("SourceControl.Git.Extension") - Quit ##super(initvalue) + set ..WebAppPath = ##class(%File).TempFilename()_"d" + do ##class(%File).CreateDirectoryChain(..WebAppPath) + do ..CreateTestWebApp("/csp/git/unittest/xsl", ..WebAppPath) + return $$$OK +} + +ClassMethod CreateTestWebApp(name, path) +{ + new $namespace + set $namespace = "%SYS" + kill props + set props("Path") = path + if '##class(Security.Applications).Exists(name) { + $$$ThrowOnError(##class(Security.Applications).Create(name, .props)) + } else { + $$$ThrowOnError(##class(Security.Applications).Create(name, .props)) + } +} + +ClassMethod DeleteTestWebApp(name) +{ + + new $namespace + set $namespace = "%SYS" + if ##class(Security.Applications).Exists(name) { + $$$ThrowOnError(##class(Security.Applications).Delete(name)) + } } Method %OnClose() As %Status [ Private, ServerOnly = 1 ] { - Do ##class(%Studio.SourceControl.Interface).SourceControlClassSet(..InitialExtension) - Kill ^SYS("SourceControl") - Merge ^SYS("SourceControl") = ..SourceControlGlobal - Quit $$$OK + do ..DeleteTestWebApp("/csp/git/unittest/xsl") + do ##class(%File).RemoveDirectoryTree(..WebAppPath) + quit ##super() } Method TestImportAll() @@ -30,9 +53,13 @@ Method TestImportAll() do ..CreateTestRoutine() $$$ThrowOnError(##class(SourceControl.Git.Utils).AddToSourceControl("test.mac")) do ..CreateStrayFileInRtn() + do ..WriteFile(##class(SourceControl.Git.Settings).%New().namespaceTemp_"csp/git/unittest/xsl/test.xsl", " ") $$$ThrowOnError(##class(%Routine).Delete("test.mac")) + do ##class(%RoutineMgr).Delete("/csp/git/unittest/xsl/test.xsl") $$$ThrowOnError(##class(SourceControl.Git.Utils).ImportAll(1)) do $$$AssertTrue(##class(%Routine).Exists("test.mac")) + do $$$AssertTrue(##class(%RoutineMgr).Exists("/csp/git/unittest/xsl/test.xsl")) + do $$$AssertFilesSame(##class(SourceControl.Git.Settings).%New().namespaceTemp_"csp/git/unittest/xsl/test.xsl", ..WebAppPath_"/test.xsl") } Method CreateTestRoutine()