@@ -114,7 +114,11 @@ func isAuthError(err error) bool {
114114}
115115
116116func isIndexLockError (err error ) bool {
117+ if err == nil {
118+ return false
119+ }
117120 errString := err .Error ()
121+
118122 return strings .Contains (errString , "index.lock" ) && strings .Contains (errString , "File exists" )
119123}
120124
@@ -145,7 +149,7 @@ func fetchBlob(ctx context.Context, url string, forceUpdate bool) ([]byte, error
145149 return nil , fmt .Errorf ("git fetch failed: %w" , err )
146150 }
147151 err = runCmd (ctx , repoPath , nil , "git" , "reset" , "--hard" , "origin/HEAD" )
148- if isIndexLockError (err ) {
152+ if err != nil && isIndexLockError (err ) {
149153 // index.lock exists, likely a previous git reset got terminated and wasn't cleaned up properly.
150154 // We can remove the file and retry the command
151155 logger .Warn ("index.lock exists, attempting to remove and retry" , slog .String ("url" , ctx .Value (urlKey ).(string )))
@@ -156,7 +160,6 @@ func fetchBlob(ctx context.Context, url string, forceUpdate bool) ([]byte, error
156160 // One more attempt at git reset
157161 err = runCmd (ctx , repoPath , nil , "git" , "reset" , "--hard" , "origin/HEAD" )
158162 }
159-
160163 if err != nil {
161164 return nil , fmt .Errorf ("git reset failed: %w" , err )
162165 }
0 commit comments