Skip to content

Commit ee80d7f

Browse files
authored
Merge pull request #963 from intersystems/fix-configure-yesno
Configure prompt no longer fails with invalid boolean settings
2 parents cf5f781 + 88d92e4 commit ee80d7f

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
### Fixed
1616
- Changes to % routines mapped to the current namespace may now be added to source control and committed (#944)
1717
- Edits to a decomposed production in VS Code fixed after changes to the VS Code ObjectScript extension (#949)
18+
- Configure prompt no longer quits out with an unhelpful error if existing boolean settings are null (#962)
1819

1920
## [2.16.0] - 2026-03-06
2021

cls/SourceControl/Git/Settings.cls

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ ClassMethod CreateNamespaceTempFolder() As %Status [ Internal ]
280280
return $$$OK
281281
}
282282

283-
ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator, Internal ]
283+
ClassMethod Configure(Output sc As %Status = {$$$OK}) As %Boolean [ CodeMode = objectgenerator, Internal ]
284284
{
285285
do %code.WriteLine(" set inst = ..%New()")
286286
do %code.WriteLine(" do inst.RetrieveDefaults()")
@@ -305,6 +305,7 @@ ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator, Internal ]
305305
set promptQuoted = $replace(promptQuoted,"${username}","'""_$Username_""'")
306306
set propertyDef = ##class(%Dictionary.PropertyDefinition).%OpenId("SourceControl.Git.Settings||"_property_"")
307307
if ((propertyDef) && (propertyDef.Type = "%Boolean")) {
308+
do %code.WriteLine(" set value = ''value")
308309
do %code.WriteLine(" set response = ##class(%Library.Prompt).GetYesNo("_promptQuoted_",.value,,"_defaultPromptFlag_")")
309310
} elseif ((propertyDef) && (propertyDef.Name = "gitBinPath")) {
310311
do %code.WriteLine(" set valid = 0")
@@ -342,6 +343,7 @@ ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator, Internal ]
342343
} else {
343344
do %code.WriteLine(" set response = ##class(%Library.Prompt).GetString("_promptQuoted_",.value,,,,"_defaultPromptFlag_")")
344345
}
346+
do %code.WriteLine(" if (response = $$$ErrorResponse) { set sc = $get(%objlasterror, 0) }")
345347
do %code.WriteLine(" if response '= $$$SuccessResponse { quit 0 }")
346348
do %code.WriteLine(" set value = $zstrip(value,""<>W"")")
347349
do %code.WriteLine(" set inst."_property_" = value")

test/UnitTest/SourceControl/Git/Settings.cls

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,32 @@ Method TestSaveAndImportSettings()
107107
do $$$AssertEquals(^SYS("SourceControl","Git","settings","generatedFilesReadOnly"),"1")
108108
}
109109

110+
/// Configure routine should succeed when accepting all defaults.
111+
Method TestConfigureCHUI()
112+
{
113+
set oldRedirectIO = ##class(%Device).ReDirectIO()
114+
set oldIO = $io
115+
set st = $$$OK
116+
try {
117+
use $io::"^"_##class(%Studio.SourceControl.ItemSet).LogTags()
118+
do ##class(%Library.Device).ReDirectIO(1)
119+
set configRet = ##class(SourceControl.Git.Settings).Configure(.configSC)
120+
// test when a boolean setting is set with invalid value
121+
set ^SYS("SourceControl","Git","settings","generatedFilesReadOnly")=""
122+
set configWithInvalidRet = ##class(SourceControl.Git.Settings).Configure(.configWithInvalidSC)
123+
} catch err {
124+
set st = err.AsStatus()
125+
}
126+
use oldIO
127+
do ##class(%Device).ReDirectIO(oldRedirectIO)
128+
$$$ThrowOnError(st)
129+
do $$$AssertTrue(configRet)
130+
do $$$AssertStatusOK(configSC)
131+
do $$$AssertTrue(configWithInvalidRet)
132+
do $$$AssertStatusOK(configWithInvalidSC)
133+
do $$$AssertEquals($get(^SYS("SourceControl","Git","settings","generatedFilesReadOnly"),""), 0)
134+
}
135+
110136
Method OnBeforeAllTests() As %Status
111137
{
112138
merge ..SourceControlGlobal = ^SYS("SourceControl")

0 commit comments

Comments
 (0)