Skip to content

Commit 2c5bc8e

Browse files
committed
fix: import all now properly imports CSP files
1 parent 83c88c6 commit 2c5bc8e

File tree

4 files changed

+56
-22
lines changed

4 files changed

+56
-22
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- Fix "Export All" stopping prematurely because a tracked item no longer exist in the namespace (#821)
2121
- Import All now outputs a warning instead of an error when an item is in the wrong path (#291)
2222
- Fixed an error where classes with compilation errors would revert to broken versions on export (#830)
23+
- Fixed Import All deploying changes to files in a CSP application (#828)
2324
- Fixed installation of the package on IRIS versions with the IRISSECURITY database (#770)
2425

2526
## [2.12.2] - 2025-07-08

cls/SourceControl/Git/PackageManagerContext.cls

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ Method InternalNameSet(InternalName As %String = "") As %Status
1818
set InternalName = ##class(SourceControl.Git.Utils).NormalizeInternalName(InternalName)
1919
if (InternalName '= i%InternalName) {
2020
set i%InternalName = InternalName
21+
set resourceReference = $$$NULLOREF
2122
if (InternalName = ##class(SourceControl.Git.Settings.Document).#INTERNALNAME) {
22-
// git source control settings document is never in an IPM context
23-
quit $$$OK
24-
}
25-
if $$$comClassDefined("%IPM.ExtensionBase.Utils") {
23+
// Embedded Git settings document is never in an IPM context
24+
set ..Package = $$$NULLOREF
25+
} elseif $$$comClassDefined("%IPM.ExtensionBase.Utils") {
2626
set ..Package = ##class(%IPM.ExtensionBase.Utils).FindHomeModule(InternalName,,.resourceReference)
2727
} elseif $$$comClassDefined("%ZPM.PackageManager.Developer.Extension.Utils") {
2828
set ..Package = ##class(%ZPM.PackageManager.Developer.Extension.Utils).FindHomeModule(InternalName,,.resourceReference)
2929
} else {
30-
quit $$$OK
30+
set ..Package = $$$NULLOREF
3131
}
3232
set ..ResourceReference = resourceReference
3333
set ..IsInGitEnabledPackage = $isobject(..Package) && ##class(%Library.File).Exists(##class(%Library.File).NormalizeFilename(".git",..Package.Root))

cls/SourceControl/Git/Utils.cls

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,8 +1468,8 @@ ClassMethod ImportCSPFile(InternalName As %String) As %Status
14681468
Quit $$$OK
14691469
}
14701470
// Delete original if exists, otherwise create new file
1471-
if '(##class(%File).CopyFile(srcFile, cspFile, 1)) {
1472-
set sc = $$$ERROR($$$GeneralError, "Unable to import '"_srcFile_"'")
1471+
if '(##class(%File).CopyFile(srcFile, cspFile, 1, .ret)) {
1472+
set sc = $$$ERROR($$$GeneralError,"Unable to copy CSP file from "_srcFile_" to "_cspFile_": return code "_ret)
14731473
}
14741474

14751475
Quit sc
@@ -1486,8 +1486,12 @@ ClassMethod ListItemsRecursively(type, fileSpec, directory, ByRef itemList) [ Pr
14861486
set internalName = files.ItemName
14871487
if ($zconvert(type,"l") = "ptd") {
14881488
do ##class(SourceControl.Git.Production).ParseExternalName($translate(files.Name,"\","/"), .internalName)
1489+
} else {
1490+
set internalName = ..NameToInternalName(files.Name,,0)
1491+
}
1492+
if (internalName '= "") {
1493+
set itemList(internalName) = ""
14891494
}
1490-
set itemList(internalName) = ""
14911495
}
14921496
}
14931497
}
@@ -1515,7 +1519,9 @@ ClassMethod ListItemsInFiles(ByRef itemList, ByRef err) As %Status
15151519
set mappedFilePath = ##class(%File).NormalizeFilename(mappedRelativePath, ..TempFolder())
15161520

15171521
if (##class(%File).DirectoryExists(mappedFilePath)){
1518-
if ..UserTypeCached("foo."_mappingFileType, .userTypeClass) {
1522+
if (mappingFileType = "/CSP/") {
1523+
do ..ListItemsRecursively(mappingFileType,"*",mappedFilePath,.itemList)
1524+
} elseif ..UserTypeCached("foo."_mappingFileType, .userTypeClass) {
15191525
set fileSpec = $select(
15201526
userTypeClass="Ens.Util.ProjectTextDocument": "*.xml;*.XML",
15211527
1: "*."_$zcvt(mappingFileType,"L")_";*."_$zconvert(mappingFileType,"U"))
@@ -1599,7 +1605,7 @@ ClassMethod ImportRoutines(force As %Boolean = 0, pullEventClass As %String) As
15991605

16001606
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(internalName)
16011607
continue:context.Package'=refPackage
1602-
set doImport = ..IsRoutineOutdated(internalName) || force
1608+
set doImport = force || ..IsRoutineOutdated(internalName)
16031609
if '..IsInSourceControl(internalName) {
16041610
set sc = ..AddToServerSideSourceControl(internalName)
16051611
if $$$ISERR(sc) {

test/UnitTest/SourceControl/Git/ImportAll.cls

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,65 @@
1-
Class UnitTest.SourceControl.Git.ImportAll Extends %UnitTest.TestCase
1+
Class UnitTest.SourceControl.Git.ImportAll Extends UnitTest.SourceControl.Git.AbstractTest
22
{
33

4-
Property InitialExtension As %String [ InitialExpression = {##class(%Studio.SourceControl.Interface).SourceControlClassGet()} ];
5-
6-
Property SourceControlGlobal [ MultiDimensional ];
4+
Property WebAppPath As %String;
75

86
Method %OnNew(initvalue) As %Status
97
{
10-
Merge ..SourceControlGlobal = ^SYS("SourceControl")
8+
$$$QuitOnError(##super(initvalue))
119
Kill ^SYS("SourceControl")
10+
/// add mappings for MAC and CSP
1211
Set settings = ##class(SourceControl.Git.Settings).%New()
13-
Set settings.namespaceTemp = ##class(%Library.File).TempFilename()_"dir"
1412
Set settings.Mappings("MAC","*")="rtn/"
13+
Set settings.Mappings("/CSP/","/csp/git/unittest/xsl")="csp/git/unittest/xsl"
1514
$$$ThrowOnError(settings.%Save())
16-
Do ##class(%Studio.SourceControl.Interface).SourceControlClassSet("SourceControl.Git.Extension")
17-
Quit ##super(initvalue)
15+
set ..WebAppPath = ##class(%File).TempFilename()_"d"
16+
do ##class(%File).CreateDirectoryChain(..WebAppPath)
17+
do ..CreateTestWebApp("/csp/git/unittest/xsl", ..WebAppPath)
18+
return $$$OK
19+
}
20+
21+
ClassMethod CreateTestWebApp(name, path)
22+
{
23+
new $namespace
24+
set $namespace = "%SYS"
25+
kill props
26+
set props("Path") = path
27+
if '##class(Security.Applications).Exists(name) {
28+
$$$ThrowOnError(##class(Security.Applications).Create(name, .props))
29+
} else {
30+
$$$ThrowOnError(##class(Security.Applications).Create(name, .props))
31+
}
32+
}
33+
34+
ClassMethod DeleteTestWebApp(name)
35+
{
36+
37+
new $namespace
38+
set $namespace = "%SYS"
39+
if ##class(Security.Applications).Exists(name) {
40+
$$$ThrowOnError(##class(Security.Applications).Delete(name))
41+
}
1842
}
1943

2044
Method %OnClose() As %Status [ Private, ServerOnly = 1 ]
2145
{
22-
Do ##class(%Studio.SourceControl.Interface).SourceControlClassSet(..InitialExtension)
23-
Kill ^SYS("SourceControl")
24-
Merge ^SYS("SourceControl") = ..SourceControlGlobal
25-
Quit $$$OK
46+
do ..DeleteTestWebApp("/csp/git/unittest/xsl")
47+
do ##class(%File).RemoveDirectoryTree(..WebAppPath)
48+
quit ##super()
2649
}
2750

2851
Method TestImportAll()
2952
{
3053
do ..CreateTestRoutine()
3154
$$$ThrowOnError(##class(SourceControl.Git.Utils).AddToSourceControl("test.mac"))
3255
do ..CreateStrayFileInRtn()
56+
do ..WriteFile(##class(SourceControl.Git.Settings).%New().namespaceTemp_"csp/git/unittest/xsl/test.xsl", "<?xml version=""1.0"" encoding=""UTF-8""?> <xsl:stylesheet version=""1.0""></xsl:stylesheet>")
3357
$$$ThrowOnError(##class(%Routine).Delete("test.mac"))
58+
do ##class(%RoutineMgr).Delete("/csp/git/unittest/xsl/test.xsl")
3459
$$$ThrowOnError(##class(SourceControl.Git.Utils).ImportAll(1))
3560
do $$$AssertTrue(##class(%Routine).Exists("test.mac"))
61+
do $$$AssertTrue(##class(%RoutineMgr).Exists("/csp/git/unittest/xsl/test.xsl"))
62+
do $$$AssertFilesSame(##class(SourceControl.Git.Settings).%New().namespaceTemp_"csp/git/unittest/xsl/test.xsl", ..WebAppPath_"/test.xsl")
3663
}
3764

3865
Method CreateTestRoutine()

0 commit comments

Comments
 (0)