@@ -119,10 +119,8 @@ async function fetchReleaseFromGithub(
119119
120120export async function checkForExtensionUpdate (
121121 extension : GeminiCLIExtension ,
122- setExtensionUpdateState : ( updateState : ExtensionUpdateState ) => void ,
123122 cwd : string = process . cwd ( ) ,
124- ) : Promise < void > {
125- setExtensionUpdateState ( ExtensionUpdateState . CHECKING_FOR_UPDATES ) ;
123+ ) : Promise < ExtensionUpdateState > {
126124 const installMetadata = extension . installMetadata ;
127125 if ( installMetadata ?. type === 'local' ) {
128126 const newExtension = loadExtension ( {
@@ -133,38 +131,32 @@ export async function checkForExtensionUpdate(
133131 console . error (
134132 `Failed to check for update for local extension "${ extension . name } ". Could not load extension from source path: ${ installMetadata . source } ` ,
135133 ) ;
136- setExtensionUpdateState ( ExtensionUpdateState . ERROR ) ;
137- return ;
134+ return ExtensionUpdateState . ERROR ;
138135 }
139136 if ( newExtension . config . version !== extension . version ) {
140- setExtensionUpdateState ( ExtensionUpdateState . UPDATE_AVAILABLE ) ;
141- return ;
137+ return ExtensionUpdateState . UPDATE_AVAILABLE ;
142138 }
143- setExtensionUpdateState ( ExtensionUpdateState . UP_TO_DATE ) ;
144- return ;
139+ return ExtensionUpdateState . UP_TO_DATE ;
145140 }
146141 if (
147142 ! installMetadata ||
148143 ( installMetadata . type !== 'git' &&
149144 installMetadata . type !== 'github-release' )
150145 ) {
151- setExtensionUpdateState ( ExtensionUpdateState . NOT_UPDATABLE ) ;
152- return ;
146+ return ExtensionUpdateState . NOT_UPDATABLE ;
153147 }
154148 try {
155149 if ( installMetadata . type === 'git' ) {
156150 const git = simpleGit ( extension . path ) ;
157151 const remotes = await git . getRemotes ( true ) ;
158152 if ( remotes . length === 0 ) {
159153 console . error ( 'No git remotes found.' ) ;
160- setExtensionUpdateState ( ExtensionUpdateState . ERROR ) ;
161- return ;
154+ return ExtensionUpdateState . ERROR ;
162155 }
163156 const remoteUrl = remotes [ 0 ] . refs . fetch ;
164157 if ( ! remoteUrl ) {
165158 console . error ( `No fetch URL found for git remote ${ remotes [ 0 ] . name } .` ) ;
166- setExtensionUpdateState ( ExtensionUpdateState . ERROR ) ;
167- return ;
159+ return ExtensionUpdateState . ERROR ;
168160 }
169161
170162 // Determine the ref to check on the remote.
@@ -174,8 +166,7 @@ export async function checkForExtensionUpdate(
174166
175167 if ( typeof lsRemoteOutput !== 'string' || lsRemoteOutput . trim ( ) === '' ) {
176168 console . error ( `Git ref ${ refToCheck } not found.` ) ;
177- setExtensionUpdateState ( ExtensionUpdateState . ERROR ) ;
178- return ;
169+ return ExtensionUpdateState . ERROR ;
179170 }
180171
181172 const remoteHash = lsRemoteOutput . split ( '\t' ) [ 0 ] ;
@@ -185,21 +176,17 @@ export async function checkForExtensionUpdate(
185176 console . error (
186177 `Unable to parse hash from git ls-remote output "${ lsRemoteOutput } "` ,
187178 ) ;
188- setExtensionUpdateState ( ExtensionUpdateState . ERROR ) ;
189- return ;
179+ return ExtensionUpdateState . ERROR ;
190180 }
191181 if ( remoteHash === localHash ) {
192- setExtensionUpdateState ( ExtensionUpdateState . UP_TO_DATE ) ;
193- return ;
182+ return ExtensionUpdateState . UP_TO_DATE ;
194183 }
195- setExtensionUpdateState ( ExtensionUpdateState . UPDATE_AVAILABLE ) ;
196- return ;
184+ return ExtensionUpdateState . UPDATE_AVAILABLE ;
197185 } else {
198186 const { source, releaseTag } = installMetadata ;
199187 if ( ! source ) {
200188 console . error ( `No "source" provided for extension.` ) ;
201- setExtensionUpdateState ( ExtensionUpdateState . ERROR ) ;
202- return ;
189+ return ExtensionUpdateState . ERROR ;
203190 }
204191 const { owner, repo } = parseGitHubRepoForReleases ( source ) ;
205192
@@ -209,18 +196,15 @@ export async function checkForExtensionUpdate(
209196 installMetadata . ref ,
210197 ) ;
211198 if ( releaseData . tag_name !== releaseTag ) {
212- setExtensionUpdateState ( ExtensionUpdateState . UPDATE_AVAILABLE ) ;
213- return ;
199+ return ExtensionUpdateState . UPDATE_AVAILABLE ;
214200 }
215- setExtensionUpdateState ( ExtensionUpdateState . UP_TO_DATE ) ;
216- return ;
201+ return ExtensionUpdateState . UP_TO_DATE ;
217202 }
218203 } catch ( error ) {
219204 console . error (
220205 `Failed to check for updates for extension "${ installMetadata . source } ": ${ getErrorMessage ( error ) } ` ,
221206 ) ;
222- setExtensionUpdateState ( ExtensionUpdateState . ERROR ) ;
223- return ;
207+ return ExtensionUpdateState . ERROR ;
224208 }
225209}
226210export interface GitHubDownloadResult {
0 commit comments