From de0569b46bbecc7f17063e78cc411c368929afff Mon Sep 17 00:00:00 2001 From: Sarmishta Velury Date: Thu, 18 Nov 2021 11:47:11 -0500 Subject: [PATCH 1/3] Removing from source control now works --- cls/SourceControl/Git/Utils.cls | 47 ++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index 98cfa5af..2c6f20af 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -9,6 +9,8 @@ Parameter InstallNamespace = "%SYS"; Parameter Slash = {$case($system.Version.GetOS(),"Windows":"\",:"/")}; +Parameter NotMySlash = {$case($system.Version.GetOS(),"Windows":"/",:"\")}; + /// Name of the file with version controlled items Parameter SCListFilename = "sc-list.txt"; @@ -122,6 +124,20 @@ ClassMethod AddSlash(path As %String) As %String quit path } +ClassMethod FixSlashes(path As %String) As %String +{ + set fixedPath = "" + if (path '= ""){ + for i=1:1:$LENGTH(path,..#NotMySlash){ + if (($PIECE(path, ..#NotMySlash, i) '= "") || (i=1)) { + set fixedPath = fixedPath_$PIECE(path, ..#NotMySlash, i)_..#Slash + } + } + } + + quit fixedPath +} + ClassMethod IsMenuGitCommand(menuItemName As %String) As %Boolean [ CodeMode = expression ] { $Find(..#GitMenuItems, ","_menuItemName_",") > 0 @@ -402,6 +418,13 @@ ClassMethod AddToSourceControl(InternalName As %String) As %Status quit ec } +ClassMethod RemoveFromGit(InternalName) +{ + #dim fullName = ##class(Utils).FullExternalName(InternalName) + do ..RunGitCommand("rm",.errStream,.outStream,"--cached", fullName) + do errStream.OutputToDevice() +} + ClassMethod DeleteExternalsForItem(InternalName As %String) As %Status { #dim type as %String = ..Type(InternalName) @@ -425,6 +448,7 @@ ClassMethod DeleteExternalsForItem(InternalName As %String) As %Status if 'sc { set ec = $$$ADDSC(ec, sc) } + do ..RemoveFromGit(item) } } } else { @@ -435,6 +459,7 @@ ClassMethod DeleteExternalsForItem(InternalName As %String) As %Status ClassMethod RemoveFromSourceControl(InternalName As %String) As %Status { + write ! #dim sc as %Status = $$$OK for i = 1:1:$length(InternalName, ",") { #dim tsc as %Status = $$$OK @@ -828,8 +853,28 @@ ClassMethod ImportItem(InternalName As %String, force As %Boolean = 0, verbose A ClassMethod ListItemsInFiles(ByRef itemList, ByRef err) As %Status { #define DoNotLoad 1 - set res = $system.OBJ.ImportDir(..TempFolder(),"*.xml","-d",.err,1, .itemList, $$$DoNotLoad) + set mappingFileType = $order($$$SourceMapping("")) + while (mappingFileType '= "") { + + set mappingCoverage = $order($$$SourceMapping(mappingFileType, "")) + + while (mappingCoverage '= ""){ + + set mappedRelativePath = $$$SourceMapping(mappingFileType, mappingCoverage) + set mappedFilePath = ..FixSlashes(..TempFolder()_(mappedRelativePath)) + + if (##class(%File).DirectoryExists(mappedFilePath)){ + set res = $system.OBJ.ImportDir(mappedFilePath,,"-d",.err,1, .tempItemList, $$$DoNotLoad) + merge itemList = tempItemList + } + + set mappingCoverage = $order($$$SourceMapping(mappingFileType, mappingCoverage)) + } + + set mappingFileType = $order($$$SourceMapping(mappingFileType)) + } + if '$data(itemList) && $$$ISERR(res) { quit res } From e6cc8d88ca600255640021d73d2a045181bb05e1 Mon Sep 17 00:00:00 2001 From: Sarmishta Velury Date: Thu, 18 Nov 2021 11:59:06 -0500 Subject: [PATCH 2/3] Call git rm for individual files as well --- cls/SourceControl/Git/Utils.cls | 1 + 1 file changed, 1 insertion(+) diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index 2c6f20af..291023f0 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -453,6 +453,7 @@ ClassMethod DeleteExternalsForItem(InternalName As %String) As %Status } } else { set ec = ..DeleteExternalFile(InternalName) + do ..RemoveFromGit(InternalName) } quit ec } From ef212bc2f64e89279ea758a430d330c241f939ba Mon Sep 17 00:00:00 2001 From: Sarmishta Velury Date: Mon, 29 Nov 2021 15:33:35 -0800 Subject: [PATCH 3/3] Replaced custom function with library function --- cls/SourceControl/Git/Utils.cls | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index 291023f0..00c96670 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -9,8 +9,6 @@ Parameter InstallNamespace = "%SYS"; Parameter Slash = {$case($system.Version.GetOS(),"Windows":"\",:"/")}; -Parameter NotMySlash = {$case($system.Version.GetOS(),"Windows":"/",:"\")}; - /// Name of the file with version controlled items Parameter SCListFilename = "sc-list.txt"; @@ -124,20 +122,6 @@ ClassMethod AddSlash(path As %String) As %String quit path } -ClassMethod FixSlashes(path As %String) As %String -{ - set fixedPath = "" - if (path '= ""){ - for i=1:1:$LENGTH(path,..#NotMySlash){ - if (($PIECE(path, ..#NotMySlash, i) '= "") || (i=1)) { - set fixedPath = fixedPath_$PIECE(path, ..#NotMySlash, i)_..#Slash - } - } - } - - quit fixedPath -} - ClassMethod IsMenuGitCommand(menuItemName As %String) As %Boolean [ CodeMode = expression ] { $Find(..#GitMenuItems, ","_menuItemName_",") > 0 @@ -863,7 +847,7 @@ ClassMethod ListItemsInFiles(ByRef itemList, ByRef err) As %Status while (mappingCoverage '= ""){ set mappedRelativePath = $$$SourceMapping(mappingFileType, mappingCoverage) - set mappedFilePath = ..FixSlashes(..TempFolder()_(mappedRelativePath)) + set mappedFilePath = ##class(%File).NormalizeFilename(mappedRelativePath, ..TempFolder()) if (##class(%File).DirectoryExists(mappedFilePath)){ set res = $system.OBJ.ImportDir(mappedFilePath,,"-d",.err,1, .tempItemList, $$$DoNotLoad)