@@ -176,6 +176,13 @@ ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator ]
176176 set propertyDef = ##class (%Dictionary.PropertyDefinition ).%OpenId (" SourceControl.Git.Settings||" _property _" " )
177177 if ((propertyDef ) && (propertyDef .Type = " %Boolean" )) {
178178 do %code .WriteLine (" set response = ##class(%Library.Prompt).GetYesNo(" _promptQuoted _" ,.value,," _defaultPromptFlag _" )" )
179+ } elseif ((propertyDef ) && (propertyDef .Name = " gitBinPath" )) {
180+ do %code .WriteLine (" set valid = 0" )
181+ do %code .WriteLine (" while ('valid) {" )
182+ do %code .WriteLine (" set response = ##class(%Library.Prompt).GetString(" _promptQuoted _" ,.value,,,," _defaultPromptFlag _" )" )
183+ do %code .WriteLine (" set status = inst.ConfigureBinPath(.value)" )
184+ do %code .WriteLine (" if (status) { set valid = 1 }" )
185+ do %code .WriteLine (" }" )
179186 } elseif ((propertyDef ) && (propertyDef .Name = " basicMode" )) {
180187 set basicModePromptFlag = defaultPromptFlag + $$$MatchExactArrayMask + $$$InitialDisplayMask
181188 do %code .WriteLine (" set list(1) = " " Yes" " " )
@@ -347,4 +354,36 @@ Method OnAfterConfigure() As %Boolean
347354 }
348355}
349356
357+ Method ConfigureBinPath (ByRef path As %String ) As %Boolean
358+ {
359+ if (path = " " ) { return 1 }
360+ // Sometimes path is quoted
361+ set path = $replace (path ," " " " ," " )
362+ if (##class (%File ).DirectoryExists (path )) {
363+ set gitFile = $case ($$$isWINDOWS,1 :" git.exe" ,:" git" )
364+ set path = ##class (%File ).Construct (path , gitFile )
365+ }
366+
367+ if (##class (%File ).Exists (path )) {
368+ // no-op
369+ } else {
370+ write !, " The entered path is not a valid path, please try again"
371+ return 0
372+ }
373+ try {
374+ set sysStorage = ##class (SourceControl.Git.Utils ).%SYSNamespaceStorage ()
375+ kill @sysStorage @(" %gitBinPath" )
376+ if (..gitBinPath '= " " ) {
377+ set @sysStorage @(" %gitBinPath" ) = path
378+ }
379+ kill ^||GitVersion
380+ // Get and write the version
381+ set gitExists = ##class (SourceControl.Git.Utils ).GitBinExists (.version )
382+ write !, " You are now using " _version
383+ } catch e {
384+ // no-op, user may not have privileges
385+ }
386+ return 1
387+ }
388+
350389}
0 commit comments