diff --git a/CHANGELOG.md b/CHANGELOG.md index 45b700bd..c4e39089 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + ## [2.4.0] - Unreleased ### Added - Pre-release support for IPM v0.9.0+ +- Items mapped from database other than namespace's default routine database are now ignored by default when exporting or adding files +- New setting to configure whether mapped items should be should be treated as read-only ## [2.3.1] - 2024-04-30 diff --git a/cls/SourceControl/Git/Change.cls b/cls/SourceControl/Git/Change.cls index e6b1e2e6..e8001143 100644 --- a/cls/SourceControl/Git/Change.cls +++ b/cls/SourceControl/Git/Change.cls @@ -217,3 +217,4 @@ Storage Default } } + diff --git a/cls/SourceControl/Git/Settings.cls b/cls/SourceControl/Git/Settings.cls index c23e32f6..297328f6 100644 --- a/cls/SourceControl/Git/Settings.cls +++ b/cls/SourceControl/Git/Settings.cls @@ -29,6 +29,9 @@ Property gitUserName As %String(MAXLEN = 255) [ InitialExpression = {##class(Sou /// Attribution: Email address for user ${username} Property gitUserEmail As %String(MAXLEN = 255) [ InitialExpression = {##class(SourceControl.Git.Utils).GitUserEmail()} ]; +/// Attribution: Whether mapped items should be read-only, preventing them from being added to source control +Property mappedItemsReadOnly As %Boolean [ InitialExpression = {##class(SourceControl.Git.Utils).MappedItemsReadOnly()} ]; + Property Mappings [ MultiDimensional ]; Method %OnNew() As %Status @@ -80,6 +83,7 @@ Method %Save() As %Status set @storage@("settings","pullEventClass") = ..pullEventClass set @storage@("settings","percentClassReplace") = ..percentClassReplace set @storage@("settings","settingsUIReadOnly") = ..settingsUIReadOnly + set @storage@("settings", "mappedItemsReadOnly") = ..mappedItemsReadOnly kill @##class(SourceControl.Git.Utils).MappingsNode() merge @##class(SourceControl.Git.Utils).MappingsNode() = ..Mappings @@ -109,6 +113,7 @@ ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator ] do %code.WriteLine(" set response = ##class(%Library.Prompt).GetString("_promptQuoted_",.value,,,,"_defaultPromptFlag_")") do %code.WriteLine(" if response '= $$$SuccessResponse { quit 0 }") do %code.WriteLine(" set inst."_property_" = value") + } do %code.WriteLine(" $$$ThrowOnError(inst.%Save())") do %code.WriteLine(" write !,""Settings saved.""") diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index eba067b9..74f809b0 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -113,6 +113,11 @@ ClassMethod GitBinPath(Output isDefault) As %String quit $case($extract(binPath),"""":binPath,:""""_binPath_"""") } +ClassMethod MappedItemsReadOnly() As %Boolean +{ + quit $get(@..#Storage@("settings", "mappedItemsReadOnly"), 1) +} + ClassMethod GitUserName() As %String { quit $get(@..#Storage@("settings","user",$username,"gitUserName"),$username) @@ -508,6 +513,7 @@ ClassMethod AddToServerSideSourceControl(InternalName As %String) As %Status ClassMethod AddToSourceControl(InternalName As %String) As %Status { + set settings = ##class(SourceControl.Git.Settings).%New() #dim i as %Integer #dim ec as %Status = $$$OK for i = 1:1:$length(InternalName, ",") { @@ -518,11 +524,18 @@ ClassMethod AddToSourceControl(InternalName As %String) As %Status if 'sc { set ec = $$$ADDSC(ec, sc) } + for i=1:1:$Get(filenames) { set FileInternalName = ##class(SourceControl.Git.Utils).NormalizeExtension(##class(SourceControl.Git.Utils).NameToInternalName(filenames(i), 0,,1)) if (FileInternalName = "") { continue } + + // Items mapped to namespace's non default routine database are ignored if set to be read-only + if (settings.mappedItemsReadOnly && ..FileIsMapped(InternalName)) { + continue + } + set FileType = ##class(SourceControl.Git.Utils).Type(.FileInternalName) set @..#Storage@("items", FileInternalName) = "" @@ -1334,6 +1347,8 @@ ClassMethod ExportRoutinesAux(path As %String, sep As %String = "", level As %In ClassMethod ExportItem(InternalName As %String, expand As %Boolean = 1, force As %Boolean = 0, ByRef filenames) As %Status { + set settings = ##class(SourceControl.Git.Settings).%New() + #dim type = ..Type(.InternalName) if type = "pkg" { $$$QuitOnError(..ExportRoutinesAux(..NameWithoutExtension(InternalName), ".", 0, force, .filenames)) @@ -1349,6 +1364,12 @@ ClassMethod ExportItem(InternalName As %String, expand As %Boolean = 1, force As write "Did not find a matching mapping for """_InternalName_""". Skipping export." quit $$$OK } + + // Items mapped to namespace's non default routine database are ignored if set to be read-only + if (..FileIsMapped(InternalName) && settings.mappedItemsReadOnly) { + write "Mapping to another database found. Skipping export" + quit $$$OK + } set filenames($I(filenames)) = filename write !, "exporting new version of ", InternalName, " to ", filename $$$QuitOnError($system.OBJ.ExportUDL(InternalName, filename,"-d/diff")) @@ -1689,6 +1710,12 @@ ClassMethod UserTypeCached(Name As %String, ByRef Class As %String, ByRef Studio Quit 1 } +/// Determines whether or not a file is mapped to another database +ClassMethod FileIsMapped(InternalName As %String) As %Boolean +{ + Quit ##class(%RoutineMgr).IsMapped(InternalName) +} + /* NameToInternalName(name): given a Unix-style slash path relative to repo root, returns the internal name for that file (e.g., cls/SourceControl/Git/Utils.cls -> SourceControl.Git.Utils.CLS) diff --git a/csp/gitprojectsettings.csp b/csp/gitprojectsettings.csp index f06acdeb..09b1e8ed 100644 --- a/csp/gitprojectsettings.csp +++ b/csp/gitprojectsettings.csp @@ -47,6 +47,10 @@ body { border-left: 0px; } +.custom-switch-no-border { + border: 0px; +} + .neutral-feedback { width: 100%; margin-top: 0.25rem; @@ -70,6 +74,12 @@ body { for param="gitBinPath","namespaceTemp","privateKeyFile","pullEventClass","percentClassReplace" { set $Property(settings,param) = $Get(%request.Data(param,1)) } + + if ($Get(%request.Data("mappedItemsReadOnly", 1)) = 1) { + set settings.mappedItemsReadOnly = 1 + } else { + set settings.mappedItemsReadOnly = 0 + } set i = 1 set param = "NoFolders" kill settings.Mappings @@ -93,8 +103,7 @@ body {

-
-
+

Git Project Settings

@@ -110,16 +119,14 @@ body {

-
-
+

Settings for namespace #(..EscapeHTML(namespace))# #($select(settings.settingsUIReadOnly:"(read-only)",1:""))#


-
- +
set exists = ##class(SourceControl.Git.Utils).GitBinExists(.version) @@ -152,8 +159,7 @@ body {
-
- + set dir = ##class(%File).NormalizeDirectory(settings.namespaceTemp) if (settings.namespaceTemp '= "") && ##class(%File).DirectoryExists(dir_".git") { @@ -171,8 +177,7 @@ body { if (settings.namespaceTemp '= "") && '##class(%File).DirectoryExists(dir_".git") { &html<
-
-