Skip to content

Commit 5dd35b4

Browse files
committed
fix: add case-corrective existence check for file
Stole this from IPM Some more work needed still
1 parent 57bdc16 commit 5dd35b4

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

cls/SourceControl/Git/Utils.cls

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,45 @@ ClassMethod NormalizeFolder(folder As %String) As %String
631631

632632
ClassMethod ExternalName(InternalName As %String, ByRef MappingExists As %Boolean) As %String
633633
{
634-
quit $Replace(..Name(.InternalName,.MappingExists),"/",..#Slash)
634+
set root = ..TempFolder()
635+
set file = $Replace(..Name(.InternalName,.MappingExists),"/",..#Slash)
636+
set fullFile = root_file
637+
if '..Exists(.fullFile) {
638+
quit ""
639+
}
640+
quit $Piece(fullFile,root,2,*)
641+
}
642+
643+
/// Check if file exists but case insensitive
644+
/// Stolen from %IPM.Utils.File
645+
ClassMethod Exists(ByRef pFilename) As %Boolean
646+
{
647+
If ##class(%File).Exists(pFilename) {
648+
Return 1
649+
}
650+
Set tDirectory = ##class(%File).ParentDirectoryName(pFilename)
651+
If '##class(%File).DirectoryExists(tDirectory) {
652+
Return 0
653+
}
654+
Set tName = $Piece(pFilename, tDirectory, 2, *)
655+
Set tFileName = $Piece(tName, ".", 1, * - 1)
656+
Set tFileExt = $Piece(tName, ".", *)
657+
for tExt = $$$LOWER(tFileExt), $$$UPPER(tFileExt) {
658+
If ##class(%File).Exists(tDirectory _ tFileName _ "." _ tExt) {
659+
Set pFilename = tDirectory _ tFileName _ "." _ tExt
660+
Return 1
661+
}
662+
}
663+
set tNameLower = $$$LOWER(tName)
664+
Set rs = ##class(%File).FileSetFunc(tDirectory, "*", , 0)
665+
While rs.%Next() {
666+
set tItemNameLower = $$$LOWER(rs.ItemName)
667+
If tItemNameLower = tNameLower {
668+
Set pFilename = tDirectory _ rs.ItemName
669+
Return 1
670+
}
671+
}
672+
Return 0
635673
}
636674

637675
ClassMethod AddToServerSideSourceControl(InternalName As %String) As %Status
@@ -2696,4 +2734,3 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status
26962734
}
26972735

26982736
}
2699-

0 commit comments

Comments
 (0)