From 88d92e47550877aefbfe40e808bcd9c51c46095b Mon Sep 17 00:00:00 2001 From: Pravin Barton <9560941+isc-pbarton@users.noreply.github.com> Date: Wed, 22 Apr 2026 12:10:30 -0400 Subject: [PATCH] fix: Configure prompt fixes up invalid boolean settings, plus better error handling --- CHANGELOG.md | 1 + cls/SourceControl/Git/Settings.cls | 4 ++- test/UnitTest/SourceControl/Git/Settings.cls | 26 ++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4d1020b..7785237f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Changes to % routines mapped to the current namespace may now be added to source control and committed (#944) - Edits to a decomposed production in VS Code fixed after changes to the VS Code ObjectScript extension (#949) +- Configure prompt no longer quits out with an unhelpful error if existing boolean settings are null (#962) ## [2.16.0] - 2026-03-06 diff --git a/cls/SourceControl/Git/Settings.cls b/cls/SourceControl/Git/Settings.cls index cd2b7d9a..7f871933 100644 --- a/cls/SourceControl/Git/Settings.cls +++ b/cls/SourceControl/Git/Settings.cls @@ -280,7 +280,7 @@ ClassMethod CreateNamespaceTempFolder() As %Status [ Internal ] return $$$OK } -ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator, Internal ] +ClassMethod Configure(Output sc As %Status = {$$$OK}) As %Boolean [ CodeMode = objectgenerator, Internal ] { do %code.WriteLine(" set inst = ..%New()") do %code.WriteLine(" do inst.RetrieveDefaults()") @@ -305,6 +305,7 @@ ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator, Internal ] set promptQuoted = $replace(promptQuoted,"${username}","'""_$Username_""'") set propertyDef = ##class(%Dictionary.PropertyDefinition).%OpenId("SourceControl.Git.Settings||"_property_"") if ((propertyDef) && (propertyDef.Type = "%Boolean")) { + do %code.WriteLine(" set value = ''value") do %code.WriteLine(" set response = ##class(%Library.Prompt).GetYesNo("_promptQuoted_",.value,,"_defaultPromptFlag_")") } elseif ((propertyDef) && (propertyDef.Name = "gitBinPath")) { do %code.WriteLine(" set valid = 0") @@ -342,6 +343,7 @@ ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator, Internal ] } else { do %code.WriteLine(" set response = ##class(%Library.Prompt).GetString("_promptQuoted_",.value,,,,"_defaultPromptFlag_")") } + do %code.WriteLine(" if (response = $$$ErrorResponse) { set sc = $get(%objlasterror, 0) }") do %code.WriteLine(" if response '= $$$SuccessResponse { quit 0 }") do %code.WriteLine(" set value = $zstrip(value,""<>W"")") do %code.WriteLine(" set inst."_property_" = value") diff --git a/test/UnitTest/SourceControl/Git/Settings.cls b/test/UnitTest/SourceControl/Git/Settings.cls index d9e47b4f..038e2dd6 100644 --- a/test/UnitTest/SourceControl/Git/Settings.cls +++ b/test/UnitTest/SourceControl/Git/Settings.cls @@ -107,6 +107,32 @@ Method TestSaveAndImportSettings() do $$$AssertEquals(^SYS("SourceControl","Git","settings","generatedFilesReadOnly"),"1") } +/// Configure routine should succeed when accepting all defaults. +Method TestConfigureCHUI() +{ + set oldRedirectIO = ##class(%Device).ReDirectIO() + set oldIO = $io + set st = $$$OK + try { + use $io::"^"_##class(%Studio.SourceControl.ItemSet).LogTags() + do ##class(%Library.Device).ReDirectIO(1) + set configRet = ##class(SourceControl.Git.Settings).Configure(.configSC) + // test when a boolean setting is set with invalid value + set ^SYS("SourceControl","Git","settings","generatedFilesReadOnly")="" + set configWithInvalidRet = ##class(SourceControl.Git.Settings).Configure(.configWithInvalidSC) + } catch err { + set st = err.AsStatus() + } + use oldIO + do ##class(%Device).ReDirectIO(oldRedirectIO) + $$$ThrowOnError(st) + do $$$AssertTrue(configRet) + do $$$AssertStatusOK(configSC) + do $$$AssertTrue(configWithInvalidRet) + do $$$AssertStatusOK(configWithInvalidSC) + do $$$AssertEquals($get(^SYS("SourceControl","Git","settings","generatedFilesReadOnly"),""), 0) +} + Method OnBeforeAllTests() As %Status { merge ..SourceControlGlobal = ^SYS("SourceControl")