diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index 2fe34681..8635dba9 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -450,7 +450,7 @@ ClassMethod AddToSourceControl(InternalName As %String) As %Status set @..#Storage@("items", item) = "" } - #dim sc as %Status = ..ExportItem(item,,,.filenames) + #dim sc as %Status = ..ExportItem(item,,1,.filenames) if 'sc { set ec = $$$ADDSC(ec, sc) } @@ -1437,7 +1437,7 @@ ClassMethod Name(InternalName As %String) As %String quit "" } - set default=1 + set default=0 set p=$order($$$SourceMapping(ext,nam)) for{ set p=$order($$$SourceMapping(ext,p),-1) @@ -1447,9 +1447,10 @@ ClassMethod Name(InternalName As %String) As %String } } - if ($data(found)=0) && ($data($$$SourceMapping(ext,"*"),found)) && ('$$$GetSourceMapping(ext,"*","NoFolders")){ + if ($data(found)=0) && ($data($$$SourceMapping(ext,"*"),found)=1) && ('$$$GetSourceMapping(ext,"*","NoFolders")){ + set default=1 + } elseif ($data(found)=0) && ($data($$$SourceMapping(ext,"*","NoFolders"), found)){ set default=0 - } elseif $data(found)=0{ set found = $zconvert(ext,"L")_"/" } @@ -1465,15 +1466,15 @@ ClassMethod Name(InternalName As %String) As %String quit $translate(found_$replace($translate(nam,"% ","__"),"-","/",1,1)_".xml","\","/") } elseif ext="CLS"||(ext="PRJ")||(usertype&&(##class(%RoutineMgr).UserType(InternalName))) { - set nam=$translate(nam,"%", ..PercentClassReplace()) - if '$$$GetSourceMapping(ext,"*","NoFolders"){ + set nam=$replace(nam,"%", ..PercentClassReplace()) + if '$data($$$SourceMapping(ext,"*","NoFolders")){ set nam=$translate(nam,".","/") } #; If match ends in '`' character use UDL/CLS format rather than XML format return $translate(found_nam_"."_$zconvert(ext, "l"),"\","/") } - if ('default){ + if (default){ quit $translate($get(found)_$translate(nam,"%.","_/")_"."_$zconvert(ext,"l"),"\","/") } else { quit $translate($get(found)_nam_"."_$zconvert(ext,"l"),"\","/") @@ -1503,35 +1504,28 @@ ClassMethod NameToInternalName(Name, IgnorePercent = 1, IgnoreNonexistent = 1) A &sql(SELECT internalName into :InternalName FROM SourceControl_Git.Change where ItemFile = :Name) if (SQLCODE = 100) { set InternalName = "" + } else{ + set Deleted = 1 } - set Deleted = 1 } if (InternalName="") { - if ($zconvert(Name,"U")'[$zconvert($$$SourceRoot,"U")) { - quit "" // file is not in ^Sources so translation cannot occur - } set name=$extract(Name,$length($$$SourceRoot)+1,*) set name=$replace(name,"\","/") // standardize slash direction - if (name["/") { - //file is in a subdirectory under the ^Sources root - set nam=$piece(name,"/",2,$length(name,"/")),extDir=$piece(name,"/")_"/" - if nam="" quit "" - - set queryary=$query($$$SourceMapping(""),-1,dir), subscript=$qsubscript(queryary,1) - while (queryary'="")&&(subscript'=0) { - if (dir["/")&&(dir=extDir) { - set ext=subscript - quit - } - set queryary=$query(@queryary,-1,dir) - if (queryary="") { - quit - } - set subscript=$qsubscript(queryary,1) + //file is in a subdirectory under the ^Sources root + set nam = name + + set queryary=$query($$$SourceMapping(""),-1,dir), mappingsSubscript = $qsubscript(queryary,4), subscript=$qsubscript(queryary,5) + while (queryary'="")&&(mappingsSubscript="mappings") { + if (dir["/")&&(dir=$extract(name, 1, $length(dir))) { + set ext=subscript + set nam = $extract(name, $length(dir)+1, *) + quit } - } else { - //there is no leading directory to remove - set nam=name + set queryary=$query(@queryary,-1,dir) + if (queryary="") { + quit + } + set mappingsSubscript = $qsubscript(queryary,4), subscript=$qsubscript(queryary,5) } if ($get(ext)="/CSP/") { @@ -1555,19 +1549,15 @@ ClassMethod NameToInternalName(Name, IgnorePercent = 1, IgnoreNonexistent = 1) A set InternalName = "" } } - set fileExt=$zconvert($piece(nam,".",$length(nam,".")),"L") - if (InternalName="")&&('$data(ext)=0)&&('$listfind($listbuild("xml","rtn"),fileExt)) { - //no match found yet, and this is in a subdir for a specific document type (ext), however it is not in a typical export format - //so treat it as a non-mapped file - kill ext - } if $data(ext)=0 { quit "" } + set fileExt=$zconvert(ext,"L") if (InternalName="") { //take our best guess based on the document extension mapped to that subdirectory - set nam=$piece(nam,".",1*-1) - set nam=$translate(nam,"_/","%.") + set nam=$piece(nam,".",1,*-1) + set nam=$replace(nam, ..PercentClassReplace(), "%") + set nam=$translate(nam,"/",".") set InternalName=nam_"."_fileExt if (fileExt="cls") { // special handling for possible collissions between % and non-% classes of the same name @@ -1608,3 +1598,4 @@ ClassMethod GetSourceControlInclude() As %String } } + diff --git a/csp/gitprojectsettings.csp b/csp/gitprojectsettings.csp index 4725b0ff..c2265c98 100644 --- a/csp/gitprojectsettings.csp +++ b/csp/gitprojectsettings.csp @@ -33,6 +33,10 @@ body { border-left: none; border-radius: 0 0.25rem 0.25rem 0; } + +#NoFolders { + display: none; +} #webuiURL { display: none; } @@ -42,10 +46,6 @@ body { border: 1px solid #ced4da; border-left: 0px; } - -hr { - opacity: 0.15 -} @@ -64,14 +64,15 @@ hr { set $Property(settings,param) = $Get(%request.Data(param,1)) } set i = 1 - set param = "MappingsPath" + set param = "NoFolders" kill settings.Mappings - while ( $Get(%request.Data(param,i)) '= "" ){ + + while ( $Get(%request.Data("MappingsExt",i)) '= "" ){ if ($Get(%request.Data(param,i)) = "NoFolders"){ - set settings.Mappings($Get(%request.Data("MappingsExt",i)), $Get(%request.Data("MappingsCov",i)), $Get(%request.Data(param,i))) = 1 + set settings.Mappings($Get(%request.Data("MappingsExt",i)), $Get(%request.Data("MappingsCov",i)), $Get(%request.Data(param,i))) = $Get(%request.Data("MappingsPath",i)) } else{ - set settings.Mappings($Get(%request.Data("MappingsExt",i)), $Get(%request.Data("MappingsCov",i))) = $Get(%request.Data(param,i)) + set settings.Mappings($Get(%request.Data("MappingsExt",i)), $Get(%request.Data("MappingsCov",i))) = $Get(%request.Data("MappingsPath",i)) } set i = i+1 } @@ -97,7 +98,7 @@ hr { -
+

Settings for namespace #(..EscapeHTML(namespace))#


@@ -180,22 +181,27 @@ hr { if ($DATA(settings.Mappings(extKey, covKey)) = 1){ set checked = "checked" set activated = " active" - set readOnly = "" + set readOnly = "readonly" set mapPath = settings.Mappings(extKey, covKey) + set noFolders = """""" + set tooltipTitle = """Switch off to store files in a flat directory structure.""" } else { set checked = "" set activated = "" set readOnly = "readonly" - set mapPath = "NoFolders" + set mapPath = settings.Mappings(extKey, covKey, "NoFolders") + set noFolders = """NoFolders""" + set tooltipTitle = """Switch on to store files in folders split by '.'s in the name.""" } &html<
- -
+ + +
@@ -270,12 +273,11 @@ hr { diff --git a/test/UnitTest/SourceControl/Git/NameToInternalNameTest.cls b/test/UnitTest/SourceControl/Git/NameToInternalNameTest.cls new file mode 100644 index 00000000..3492ad43 --- /dev/null +++ b/test/UnitTest/SourceControl/Git/NameToInternalNameTest.cls @@ -0,0 +1,66 @@ +Import SourceControl.Git + +Include SourceControl.Git + +Class UnitTest.SourceControl.Git.NameToInternalNameTest Extends %UnitTest.TestCase +{ + +Property Mappings [ MultiDimensional ]; + +Method TestRegularClassNames() +{ + // Regular class that exists + do $$$AssertEquals(##class(Utils).NameToInternalName("cls\SourceControl\Git\Utils.cls"),"SourceControl.Git.Utils.CLS") + // Regular class that doesn't exist and we ignore non-existent classes + do $$$AssertEquals(##class(Utils).NameToInternalName("cls\SourceControl\Git\DoesNotExist.cls"),"") + // Regular class that doesn't exist and we don't ignore non-existent classes + do $$$AssertEquals(##class(Utils).NameToInternalName("cls\SourceControl\Git\DoesNotExist.cls", 1, 0),"SourceControl.Git.DoesNotExist.CLS") +} + +Method TestPercentClassNames() +{ + // % class that exists but we ignore % classes + do $$$AssertEquals(##class(Utils).NameToInternalName("cls\"_##class(SourceControl.Git.Utils).PercentClassReplace()_"Studio\Extension\Base.cls"),"") + // % class that exists and we don't ignore % classes + do $$$AssertEquals(##class(Utils).NameToInternalName("cls\"_##class(SourceControl.Git.Utils).PercentClassReplace()_"Studio\Extension\Base.cls", 0),"%Studio.Extension.Base.CLS") + // % class that doesn't exist and we ignore non-existent classes + do $$$AssertEquals(##class(Utils).NameToInternalName("cls\"_##class(SourceControl.Git.Utils).PercentClassReplace()_"Studio\Extension\DoesNotExist.cls", 0),"") + // % class that doesn't exist and we don't ignore non-existent classes + do $$$AssertEquals(##class(Utils).NameToInternalName("cls\"_##class(SourceControl.Git.Utils).PercentClassReplace()_"Studio\Extension\DoesNotExist.cls", 0, 0),"%Studio.Extension.DoesNotExist.CLS") +} + +Method TestAbstractDocumentClassNames() +{ + // %Studio.AbstractDocument type that exists + do $$$AssertEquals(##class(Utils).NameToInternalName("test\dfi\test2.pivot.xml"),"test2.pivot.DFI") + // %Studio.AbstractDocument type that does not exist and we ignore non-existent classes + do $$$AssertEquals(##class(Utils).NameToInternalName("test\dfi\DoesNotExist.xml"),"") + // %Studio.AbstractDocument type that doesn't exist and we don't ignore non-existent classes + do $$$AssertEquals(##class(Utils).NameToInternalName("test\dfi\DoesNotExist.xml", 1, 0),"DoesNotExist.DFI") +} + +Method TestStaticFileNames() +{ + // Static file that shouldn't be on the server + do $$$AssertEquals(##class(Utils).NameToInternalName("git-webui\src\js\git-webui.js"),"") + // Static file that shouldn't be on the server but we don't ignore non-existent classes + do $$$AssertEquals(##class(Utils).NameToInternalName("git-webui\src\js\git-webui.js", 1, 0),"") +} + +Method OnBeforeAllTests() As %Status +{ + merge ..Mappings = @##class(SourceControl.Git.Utils).MappingsNode() + kill @##class(SourceControl.Git.Utils).MappingsNode() + set $$$SourceMapping("CLS", "*") = "cls/" + set $$$SourceMapping("DFI", "*", "NoFolders") = "test/dfi/" + quit $$$OK +} + +Method %OnClose() As %Status +{ + kill @##class(SourceControl.Git.Utils).MappingsNode() + merge @##class(SourceControl.Git.Utils).MappingsNode() = ..Mappings + quit $$$OK +} + +} diff --git a/test/dfi/test2.pivot.xml b/test/dfi/test2.pivot.xml new file mode 100644 index 00000000..8c112603 --- /dev/null +++ b/test/dfi/test2.pivot.xml @@ -0,0 +1,9 @@ + + + + + + + + +