Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions cls/SourceControl/Git/PackageManagerContext.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
16 changes: 11 additions & 5 deletions cls/SourceControl/Git/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this applies to XSLT files too, I would change the language to something more generic. Suggestion: "Unable to copy application file from ..."

}

Quit sc
Expand All @@ -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) = ""
}
}
}
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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) {
Expand Down
51 changes: 39 additions & 12 deletions test/UnitTest/SourceControl/Git/ImportAll.cls
Original file line number Diff line number Diff line change
@@ -1,38 +1,65 @@
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I've done things like this (where a test case creates a record, testing a DTL, etc...), I find storing it in a class parameter helps improve code readability and makes it more explicit that this name should not change across the execution of the test case.

}

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()
{
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", "<?xml version=""1.0"" encoding=""UTF-8""?> <xsl:stylesheet version=""1.0""></xsl:stylesheet>")
$$$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()
Expand Down
Loading