@@ -178,10 +178,12 @@ export class GkCliIntegrationProvider implements Disposable {
178178 let forceInstall = false ;
179179 const cliInstall = this . container . storage . getScoped ( 'gk:cli:install' ) ;
180180 if ( cliInstall ?. status === 'completed' ) {
181- let currentCoreVersion = await this . getCliCoreVersion ( ) ;
182- const minimumVersion = await this . container . productConfig . getCliMinimumVersion ( ) ;
183- if ( ! currentCoreVersion || satisfies ( fromString ( currentCoreVersion ) , `< ${ minimumVersion } ` ) ) {
184- Logger . log ( `CLI core version ${ currentCoreVersion ?? 'unknown' } is outdated, forcing reinstall` ) ;
181+ const { needsUpdate, core, proxy } = await this . checkCliUpdateRequired ( ) ;
182+ let currentCoreVersion = core ;
183+ if ( needsUpdate !== undefined ) {
184+ Logger . log (
185+ `CLI ${ needsUpdate } version ${ ( needsUpdate === 'core' ? currentCoreVersion : proxy ) ?? 'unknown' } is outdated, forcing reinstall` ,
186+ ) ;
185187 forceInstall = true ;
186188 } else {
187189 // Only update if GitLens extension version has changed since last check, to avoid unnecessary update checks
@@ -884,20 +886,61 @@ export class GkCliIntegrationProvider implements Disposable {
884886 }
885887
886888 @log ( )
887- private async getCliCoreVersion ( force = false ) : Promise < string | undefined > {
889+ private async checkCliUpdateRequired ( ) : Promise < {
890+ needsUpdate : 'core' | 'proxy' | undefined ;
891+ core : string | undefined ;
892+ proxy : string | undefined ;
893+ } > {
888894 const scope = getLogScope ( ) ;
889895
890- if ( force || this . _cliCoreVersion == null ) {
891- try {
892- const versions = await getCLIVersions ( ) ;
893- this . _cliCoreVersion = versions ?. core ;
894- } catch ( ex ) {
895- Logger . error ( ex , scope , 'Failed to get CLI version' ) ;
896+ try {
897+ const currentVersions = await getCLIVersions ( ) ;
898+ if ( currentVersions == null ) {
896899 this . _cliCoreVersion = undefined ;
900+ return {
901+ needsUpdate : 'proxy' ,
902+ core : undefined ,
903+ proxy : undefined ,
904+ } ;
897905 }
906+
907+ const { core : currentCoreVersion , proxy : currentProxyVersion } = currentVersions ;
908+ this . _cliCoreVersion = currentCoreVersion ;
909+
910+ const { core : minimumCoreVersion , proxy : minimumProxyVersion } =
911+ await this . container . productConfig . getCliMinimumVersions ( ) ;
912+
913+ if ( satisfies ( fromString ( currentProxyVersion ) , `< ${ minimumProxyVersion } ` ) ) {
914+ return {
915+ needsUpdate : 'proxy' ,
916+ core : currentCoreVersion ,
917+ proxy : currentProxyVersion ,
918+ } ;
919+ }
920+
921+ if ( satisfies ( fromString ( currentCoreVersion ) , `< ${ minimumCoreVersion } ` ) ) {
922+ return {
923+ needsUpdate : 'core' ,
924+ core : currentCoreVersion ,
925+ proxy : currentProxyVersion ,
926+ } ;
927+ }
928+
929+ return {
930+ needsUpdate : undefined ,
931+ core : currentCoreVersion ,
932+ proxy : currentProxyVersion ,
933+ } ;
934+ } catch ( ex ) {
935+ Logger . error ( ex , scope , 'Failed to get CLI version' ) ;
936+ this . _cliCoreVersion = undefined ;
898937 }
899938
900- return this . _cliCoreVersion ;
939+ return {
940+ needsUpdate : 'proxy' ,
941+ core : undefined ,
942+ proxy : undefined ,
943+ } ;
901944 }
902945}
903946
0 commit comments