Skip to content

Fix inconsistent casing in items cache #751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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 @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Deletes are now properly owned by the user who did the delete (#729)
- Pull page output now displays better when pull preview shows a lot of changes (#740)
- extensions in item cache are consistently upper-case, so "export all" doesn't duplicate work (#727)

## [2.11.0] - 2025-04-23

Expand Down
2 changes: 1 addition & 1 deletion cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Method DeleteFile(item As %String = "", externalName As %String = "") As %Status
if deleted && $$$ISOK(sc) {
if (item '= "") {
do ##class(SourceControl.Git.Utils).RemoveRoutineTSH(item)
kill $$$TrackedItems(##class(SourceControl.Git.Utils).NormalizeExtension(item))
kill $$$TrackedItems(##class(%Studio.SourceControl.Interface).normalizeName(item))
}
} else {
if +$system.Status.GetErrorCodes(sc) = $$$ClassDoesNotExist {
Expand Down
47 changes: 20 additions & 27 deletions cls/SourceControl/Git/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ ClassMethod AddToServerSideSourceControl(InternalName As %String) As %Status
#dim i as %Integer
#dim ec as %Status = $$$OK
for i = 1:1:$length(InternalName, ",") {
#dim item as %String = ..NormalizeExtension($piece(InternalName, ",", i))
#dim item as %String = ##class(%Studio.SourceControl.Interface).normalizeName($piece(InternalName, ",", i))
if (item = "") {
continue
}
Expand All @@ -781,7 +781,7 @@ ClassMethod AddToSourceControl(InternalName As %String, refreshUncommitted As %B
#dim i as %Integer
#dim ec as %Status = $$$OK
for i = 1:1:$length(InternalName, ",") {
#dim item as %String = ..NormalizeExtension($piece(InternalName, ",", i))
#dim item as %String = ##class(%Studio.SourceControl.Interface).normalizeName($piece(InternalName, ",", i))
#dim type as %String = ..Type(.item)

#dim sc as %Status = ..ExportItem(item,,1,.filenames)
Expand All @@ -791,7 +791,7 @@ ClassMethod AddToSourceControl(InternalName As %String, refreshUncommitted As %B

for i=1:1:$Get(filenames) {
set ignoreNonexistent = (type '= "ptd")
set FileInternalName = ##class(SourceControl.Git.Utils).NormalizeExtension(
set FileInternalName = ##class(%Studio.SourceControl.Interface).normalizeName(
##class(SourceControl.Git.Utils).NameToInternalName(filenames(i), 0,ignoreNonexistent,1))
if (FileInternalName = "") {
continue
Expand Down Expand Up @@ -971,7 +971,7 @@ ClassMethod RemoveFromServerSideSourceControl(InternalName As %String) As %Statu
#dim i as %Integer
#dim ec as %Status = $$$OK
for i = 1:1:$length(InternalName, ",") {
#dim item as %String = ..NormalizeExtension($piece(InternalName, ",", i))
#dim item as %String = ##class(%Studio.SourceControl.Interface).normalizeName($piece(InternalName, ",", i))
#dim tsc as %Status = $$$OK
#dim type as %String = ..Type(.InternalName)

Expand Down Expand Up @@ -999,8 +999,8 @@ ClassMethod RemoveFromSourceControl(InternalName As %String, cascadeDelete As %B
#dim type as %String = ..Type(.InternalName)

set item = $piece(InternalName, ",", i)
if $data(@..#Storage@("items", ..NormalizeExtension(item))) {
set item = ..NormalizeExtension(item)
if $data(@..#Storage@("items", ##class(%Studio.SourceControl.Interface).normalizeName(item))) {
set item = ##class(%Studio.SourceControl.Interface).normalizeName(item)
}

if $data(@..#Storage@("items", item)) {
Expand Down Expand Up @@ -1202,21 +1202,21 @@ ClassMethod IsInSourceControl(InternalName As %String, ByRef sourceControlItem A
{
#dim isInSourceControl as %Boolean = 1
set sourceControlItem = ""
set InternalName = ##class(SourceControl.Git.Utils).NormalizeExtension(InternalName)
set InternalName = ##class(%Studio.SourceControl.Interface).normalizeName(InternalName)
if (InternalName = "") {
quit 0
}

set context = ##class(SourceControl.Git.PackageManagerContext).%Get()
if $data(@..#Storage@("items", ..NormalizeExtension(InternalName))) {
set InternalName = ..NormalizeExtension(InternalName)
if $data(@..#Storage@("items", ##class(%Studio.SourceControl.Interface).normalizeName(InternalName))) {
set InternalName = ##class(%Studio.SourceControl.Interface).normalizeName(InternalName)
}

set isInSourceControl = $data(@..#Storage@("items", InternalName)) > 0
if isInSourceControl {
// Direct reference to namespace-default project
set sourceControlItem = InternalName
} elseif context.IsInGitEnabledPackage && (InternalName = ..NormalizeExtension(context.InternalName)) {
} elseif context.IsInGitEnabledPackage && (InternalName = ##class(%Studio.SourceControl.Interface).normalizeName(context.InternalName)) {
// Next thing to check is if we're in a package manager-based package
set isInSourceControl = 1
set sourceControlItem = context.ResourceReference.Name
Expand Down Expand Up @@ -1270,7 +1270,7 @@ ClassMethod NormalizeInternalName(ByRef name As %String, Output fromWebApp As %B
set type = ..Type(.name)

if ($extract(name) '= "/") && (type'="csp") {
quit $piece(name,".",1,*-1)_"."_$zconvert($piece(name,".",*),"U")
quit ##class(%Studio.SourceControl.Interface).normalizeName(name)
}

if (name [ "/") && (type = "csp") {
Expand All @@ -1289,20 +1289,11 @@ ClassMethod NormalizeInternalName(ByRef name As %String, Output fromWebApp As %B
quit name
}

ClassMethod NormalizeExtension(name As %String) As %String
{
#dim extension = $piece(name, ".", $length(name, "."))
if $length(extension) <= 3 {
set $piece(name, ".", $length(name, ".")) = $zconvert(extension, "L")
}
quit name
}

ClassMethod RoutineTSH(InternalName As %String) As %String
{
#dim type = ..Type(InternalName)
//for csp-files (csp,js,html,css, all that stored in csp/...) we always check for changes in external file
#dim tsh = $case(type,"csp":"",:$get(@..#Storage@("TSH", ..NormalizeExtension(InternalName))))
#dim tsh = $case(type,"csp":"",:$get(@..#Storage@("TSH", ##class(%Studio.SourceControl.Interface).normalizeName(InternalName))))

// in case an OS level error is returned
set:(($$$isUNIX & (tsh = -2)) || ($$$isWINDOWS & (tsh = -3))) tsh = 0
Expand All @@ -1321,13 +1312,13 @@ ClassMethod RoutineTSH(InternalName As %String) As %String

ClassMethod UpdateRoutineTSH(InternalName As %String, tsh As %String) As %Status
{
set @..#Storage@("TSH", ..NormalizeExtension(InternalName)) = $get(tsh, $h)
set @..#Storage@("TSH", ##class(%Studio.SourceControl.Interface).normalizeName(InternalName)) = $get(tsh, $h)
quit $$$OK
}

ClassMethod RemoveRoutineTSH(InternalName As %String) As %Status
{
kill @..#Storage@("TSH", ..NormalizeExtension(InternalName))
kill @..#Storage@("TSH", ##class(%Studio.SourceControl.Interface).normalizeName(InternalName))
quit $$$OK
}

Expand Down Expand Up @@ -2272,12 +2263,14 @@ ClassMethod GitStatus(ByRef files, IncludeAllFiles = 0)
set list = $listfromstring(lines, $char(0))
set pointer = 0
while $listnext(list, pointer, item) {
set operation = $zstrip($extract(item, 1, 2), "<W")
set operation = $zstrip($extract(item, 1, 2), "<>W")
set externalName = $extract(item, 4, *)
set internalName = ..NameToInternalName(externalName,,0)
if (internalName '= "") {
set files(internalName) = $listbuild(operation, externalName)
set @..#Storage@("items",..NormalizeInternalName(internalName)) = ""
if (operation '= "D") {
set @..#Storage@("items",..NormalizeInternalName(internalName)) = ""
}
} elseif ((IncludeAllFiles) && (externalName '= "")) {
set externalName = $TRANSLATE(externalName, "\", "/")
set files($I(files)) = $listbuild(operation, externalName)
Expand Down Expand Up @@ -2399,8 +2392,8 @@ ClassMethod Name(InternalName As %String, ByRef MappingExists As %Boolean) As %S

if InternalName["/" {
// If no specific mapping was specified (p=""), then return the whole csp filename; otherwise return the name without the mapped piece
set InternalName=$extract(InternalName,$length(p)+2,*)
quit $translate(found_$translate(InternalName,"%","_"),"\","/")
set relativeInternalName=$extract(InternalName,$length(p)+2,*)
quit $translate(found_$translate(relativeInternalName,"%","_"),"\","/")
} elseif (..Type(InternalName) = "ptd") {
do ##class(SourceControl.Git.Production).ParseInternalName(InternalName,'default,.filename)
return $translate(found_filename, "\","/")
Expand Down
Loading