@@ -118,20 +118,20 @@ export async function cloneRemoteSource(
118118 )
119119 : tmpDir . name ;
120120 requireFunctionsYaml ( sourceDir ) ;
121- try {
122- const rev = spawnSync ( "git" , [ "rev-parse" , "--short" , "HEAD" ] , {
123- cwd : tmpDir . name ,
124- encoding : "utf8" ,
125- } ) ;
126- const sha = rev . status === 0 ? rev . stdout . trim ( ) : undefined ;
127- const origin = ` ${ repository } @ ${ ref } / ${ dir ?? "" } ` ;
128- if ( sha ) {
129- logLabeledBullet ( "functions" , `verified functions.yaml for ${ origin } ; using commit ${ sha } ` ) ;
130- } else {
131- logLabeledBullet ( "functions" , `verified functions.yaml in remote source ( ${ origin } )` ) ;
132- }
133- } catch {
134- const origin = ` ${ repository } @ ${ ref } / ${ dir ?? "" } ` ;
121+ const origin = ` ${ repository } @ ${ ref } ${ dir ? `/ ${ dir } ` : "" } ` ;
122+ let sha : string | undefined ;
123+ const rev = spawnSync ( "git" , [ "rev-parse" , "--short" , "HEAD" ] , {
124+ cwd : tmpDir . name ,
125+ encoding : "utf8" ,
126+ } ) ;
127+ if ( ! rev . error && rev . status === 0 ) {
128+ sha = rev . stdout . trim ( ) ;
129+ } else if ( rev . error ) {
130+ logger . debug ( "Failed to get git revision for logging:" , rev . error ) ;
131+ }
132+ if ( sha ) {
133+ logLabeledBullet ( "functions" , `verified functions.yaml for ${ origin } ; using commit ${ sha } ` ) ;
134+ } else {
135135 logLabeledBullet ( "functions" , `verified functions.yaml in remote source (${ origin } )` ) ;
136136 }
137137 logger . debug ( `Successfully cloned to ${ sourceDir } ` ) ;
@@ -202,21 +202,20 @@ async function runGitWithRetry(
202202 retries = 1 ,
203203 backoffMs = 200 ,
204204) : Promise < SpawnSyncReturns < string > > {
205- let last : SpawnSyncReturns < string > | undefined ;
206- for ( let attempt = 0 ; attempt <= retries ; attempt ++ ) {
205+ let attempt = 0 ;
206+ while ( true ) {
207207 const res = cmd ( ) ;
208- last = res ;
208+ if ( ! res . error && res . status === 0 ) {
209+ return res ;
210+ }
209211 const stderr = ( res . stderr || res . stdout || "" ) . toString ( ) ;
210- if ( ! res . error && res . status === 0 ) return res ;
211212 if ( attempt < retries && isTransientGitError ( stderr ) ) {
212- await delay ( backoffMs * Math . max ( 1 , attempt + 1 ) ) ;
213+ await delay ( backoffMs * ( attempt + 1 ) ) ;
214+ attempt ++ ;
213215 continue ;
214216 }
215217 return res ;
216218 }
217- // Should not reach here, but return last if it exists.
218- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
219- return last ! ;
220219}
221220
222221/**
0 commit comments