Skip to content

Commit 03cf3f4

Browse files
authored
Merge pull request #942 from intersystems/fix-create-dirs
Explicitly create nested subdirectories on export
2 parents d5fa0d9 + a6eaee5 commit 03cf3f4

4 files changed

Lines changed: 36 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- Fixed `<VALUE OUT OF RANGE>` error in GetTempFileAndRoutineTS when an OS-level error code was stored as a routine timestamp (#832)
1717
- Fixed issue where Generated Files Read-only option didn't entirely work for files not in source control (#712)
1818
- Fixed issue where a deleted file not within Embedded Git's management was causing the pull handler to crash and not fully update the Iris instance (#928)
19+
- Fixed exporting items in nested subdirectories in IRIS versions >= 2025.3 (#786)
1920

2021
## [2.15.0] - 2026-01-06
2122

cls/SourceControl/Git/Production.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ ClassMethod ExportProjectForPTD(productionClass As %String, ptdName As %String,
108108
$$$ThrowOnError(project.%Save())
109109
set projContentsList(exportNotesPTDName_".PTD") = ""
110110
set projContentsList(project.Name_".PRJ") = ""
111-
$$$ThrowOnError($System.OBJ.Export(.projContentsList, exportPath, "/diffexport=1"))
111+
$$$ThrowOnError($System.OBJ.Export(.projContentsList, exportPath, "/diffexport=1/createdirs=1"))
112112
// remove the LastModified timestamp from the exported file
113113
set fileStream = ##class(%Stream.FileCharacter).%OpenId(exportPath,,.st)
114114
$$$ThrowOnError(st)

cls/SourceControl/Git/Utils.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,7 @@ ClassMethod ExportItem(InternalName As %String, expand As %Boolean = 1, force As
17901790
do ..RemoveFromServerSideSourceControl(InternalName)
17911791
}
17921792
else {
1793-
$$$QuitOnError($SYSTEM.OBJ.ExportUDL(InternalName, filename,"-d/diff"))
1793+
$$$QuitOnError($SYSTEM.OBJ.ExportUDL(InternalName, filename,"-d/diff/createdirs=1"))
17941794
}
17951795
}
17961796
if (filename '= "") && ##class(%File).Exists(filename) {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Class UnitTest.SourceControl.Git.Utils.ExportItem Extends UnitTest.SourceControl.Git.AbstractTest
2+
{
3+
4+
/// Tests that ExportItem creates intermediate directories when they don't exist
5+
Method TestExportCreatesIntermediateDirectories()
6+
{
7+
set internalName = "TestGitExport.Deep.Nested.Pkg.MyClass.CLS"
8+
9+
// Create the class in the database so ExportItem has something to export
10+
set classDef = ##class(%Dictionary.ClassDefinition).%New()
11+
set classDef.Name = "TestGitExport.Deep.Nested.Pkg.MyClass"
12+
$$$ThrowOnError(classDef.%Save())
13+
14+
// Determine the expected export path and ensure its directory does NOT exist yet
15+
set filename = ##class(SourceControl.Git.Utils).FullExternalName(internalName)
16+
set dirPath = ##class(%File).GetDirectory(filename)
17+
if ##class(%File).DirectoryExists(dirPath) {
18+
do ##class(%File).RemoveDirectoryTree(dirPath)
19+
}
20+
do $$$AssertNotTrue(##class(%File).DirectoryExists(dirPath), "Directory should not exist before export")
21+
22+
// Export the item - this should succeed even without pre-existing directories
23+
do $$$AssertStatusOK(##class(SourceControl.Git.Utils).ExportItem(internalName, 0, 1))
24+
do $$$AssertTrue(##class(%File).Exists(filename))
25+
26+
// Clean up
27+
do $system.OBJ.Delete(internalName, "-d")
28+
if ##class(%File).Exists(filename) {
29+
do ##class(%File).Delete(filename)
30+
}
31+
}
32+
33+
}

0 commit comments

Comments
 (0)