@@ -170,6 +170,13 @@ ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator ]
170170 set propertyDef = ##class (%Dictionary.PropertyDefinition ).%OpenId (" SourceControl.Git.Settings||" _property _" " )
171171 if ((propertyDef ) && (propertyDef .Type = " %Boolean" )) {
172172 do %code .WriteLine (" set response = ##class(%Library.Prompt).GetYesNo(" _promptQuoted _" ,.value,," _defaultPromptFlag _" )" )
173+ } elseif ((propertyDef ) && (propertyDef .Name = " gitBinPath" )) {
174+ do %code .WriteLine (" set valid = 0" )
175+ do %code .WriteLine (" while ('valid) {" )
176+ do %code .WriteLine (" set response = ##class(%Library.Prompt).GetString(" _promptQuoted _" ,.value,,,," _defaultPromptFlag _" )" )
177+ do %code .WriteLine (" set status = inst.ConfigureBinPath(.value)" )
178+ do %code .WriteLine (" if (status) { set valid = 1 }" )
179+ do %code .WriteLine (" }" )
173180 } elseif ((propertyDef ) && (propertyDef .Name = " basicMode" )) {
174181 set basicModePromptFlag = defaultPromptFlag + $$$MatchExactArrayMask + $$$InitialDisplayMask
175182 do %code .WriteLine (" set list(1) = " " Yes" " " )
@@ -341,4 +348,36 @@ Method OnAfterConfigure() As %Boolean
341348 }
342349}
343350
351+ Method ConfigureBinPath (ByRef path As %String ) As %Boolean
352+ {
353+ if (path = " " ) { return 1 }
354+ // Sometimes path is quoted
355+ set path = $replace (path ," " " " ," " )
356+ if (##class (%File ).DirectoryExists (path )) {
357+ set gitFile = $case ($$$isWINDOWS,1 :" git.exe" ,:" git" )
358+ set path = ##class (%File ).Construct (path , gitFile )
359+ }
360+
361+ if (##class (%File ).Exists (path )) {
362+ // no-op
363+ } else {
364+ write !, " The entered path is not a valid path, please try again"
365+ return 0
366+ }
367+ try {
368+ set sysStorage = ##class (SourceControl.Git.Utils ).%SYSNamespaceStorage ()
369+ kill @sysStorage @(" %gitBinPath" )
370+ if (..gitBinPath '= " " ) {
371+ set @sysStorage @(" %gitBinPath" ) = path
372+ }
373+ kill ^||GitVersion
374+ // Get and write the version
375+ set gitExists = ##class (SourceControl.Git.Utils ).GitBinExists (.version )
376+ write !, " You are now using " _version
377+ } catch e {
378+ // no-op, user may not have privileges
379+ }
380+ return 1
381+ }
382+
344383}
0 commit comments