From f0855e8b6b6fb204c8bc32343af08b6768237d3c Mon Sep 17 00:00:00 2001 From: Rutvik Saptarshi Date: Wed, 13 Sep 2023 14:47:01 -0400 Subject: [PATCH] fixed issue #250 -- Set up default mappings with SourceControl.Git.Settings --- cls/SourceControl/Git/API.cls | 5 +---- cls/SourceControl/Git/Settings.cls | 7 ++++++- cls/SourceControl/Git/Utils.cls | 11 ++++++++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/cls/SourceControl/Git/API.cls b/cls/SourceControl/Git/API.cls index 9c960589..5e975674 100644 --- a/cls/SourceControl/Git/API.cls +++ b/cls/SourceControl/Git/API.cls @@ -12,10 +12,7 @@ ClassMethod Configure() write !,"Configured SourceControl.Git.Extension as source control class for namespace ",$namespace set mappingsNode = ##class(SourceControl.Git.Utils).MappingsNode() if '$data(@mappingsNode) { - set @mappingsNode@("CLS","*")="cls/" - set @mappingsNode@("CLS","UnitTest")="test/" - set @mappingsNode@("INC","*")="inc/" - set @mappingsNode@("MAC","*")="rtn/" + do ##class(SourceControl.Git.Utils).SetDefaultMappings(mappingsNode) write !,"Configured default mappings for classes, routines, and include files. You can customize these in the global:",!?5,mappingsNode } set gitExists = ##class(SourceControl.Git.Utils).GitBinExists(.version) diff --git a/cls/SourceControl/Git/Settings.cls b/cls/SourceControl/Git/Settings.cls index 15897a04..afe78ce4 100644 --- a/cls/SourceControl/Git/Settings.cls +++ b/cls/SourceControl/Git/Settings.cls @@ -30,7 +30,11 @@ Property Mappings [ MultiDimensional ]; Method %OnNew() As %Status { - merge ..Mappings = @##class(SourceControl.Git.Utils).MappingsNode() + set mappingsNode = ##class(SourceControl.Git.Utils).MappingsNode() + if '$data(@mappingsNode) { + do ##class(SourceControl.Git.Utils).SetDefaultMappings(mappingsNode) + } + merge ..Mappings = @mappingsNode set gitBinPath = ##class(SourceControl.Git.Utils).GitBinPath(.isDefault) if ('isDefault) { set ..gitBinPath = gitBinPath @@ -168,3 +172,4 @@ Method OnAfterConfigure() As %Boolean } } + diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index ea96b7be..7df75c0c 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -233,7 +233,8 @@ ClassMethod UserAction(InternalName As %String, MenuName As %String, ByRef Targe set ec = ..AddToSourceControl(InternalName) } elseif (menuItemName = "RemoveFromSC") { set ec = ..RemoveFromSourceControl(InternalName) - } elseif (menuItemName = "Commit") { + } // is there any reason this code block is repeated? + elseif (menuItemName = "Commit") { set Target = "Please enter a commit message" set Action = 7 quit $$$OK @@ -1986,5 +1987,13 @@ ClassMethod BuildCEInstallationPackage(ByRef destination As %String) As %Status quit sc } +ClassMethod SetDefaultMappings(mappingsNode As %String) +{ + set @mappingsNode@("CLS","*")="cls/" + set @mappingsNode@("CLS","UnitTest")="test/" + set @mappingsNode@("INC","*")="inc/" + set @mappingsNode@("MAC","*")="rtn/" +} + }