@@ -165,54 +165,55 @@ async function main() {
165165 const res = await headWithRetry ( repo . url ) ;
166166 const status = res . status ;
167167
168- const isOnline = status >= 200 && status < 400 ; // treat 2xx/3xx as online
169168 const isNotFound = status === 404 ;
170169
171- if ( isNotFound && repo . deleted_at === null ) {
172- await updateDeletedAt ( repo . id , "now" ) ;
173- markedDeleted ++ ;
174- console . log ( `${ progress } Marked deleted: ${ repo . full_name } (status ${ status } )` ) ;
175- } else if ( isOnline ) {
170+ if ( isNotFound ) {
171+ if ( repo . deleted_at === null ) {
172+ await updateDeletedAt ( repo . id , "now" ) ;
173+ markedDeleted ++ ;
174+ console . log ( `${ progress } Marked deleted: ${ repo . full_name } (status ${ status } )` ) ;
175+ } else {
176+ unchanged ++ ;
177+ if ( i % 50 === 0 ) {
178+ console . log ( `${ progress } Unchanged: ${ repo . full_name } (status ${ status } )` ) ;
179+ }
180+ }
181+ } else {
176182 // Repository is online - check if it still uses Scaffold-ETH 2
177- if ( repo . deleted_at !== null ) {
178- // Repository was previously marked as deleted but is now online
179- await updateDeletedAt ( repo . id , null ) ;
180- restored ++ ;
181- console . log ( `${ progress } Restored: ${ repo . full_name } (status ${ status } )` ) ;
183+ const branch = repo . default_branch || "main" ;
184+ const tree = await fetchGitTreeWithRetry ( repo . full_name , branch ) ;
185+
186+ if ( tree === null || tree . truncated ) {
187+ // Failed to fetch tree or tree is truncated - skip for now
188+ unchanged ++ ;
189+ if ( i % 50 === 0 ) {
190+ console . log ( `${ progress } Unchanged: ${ repo . full_name } (status ${ status } , tree fetch failed)` ) ;
191+ }
182192 } else {
183- // Check if scaffold.config.ts exists
184- // Use "main" as fallback if default_branch is null
185- const branch = repo . default_branch || "main" ;
186- const tree = await fetchGitTreeWithRetry ( repo . full_name , branch ) ;
187-
188- if ( tree === null ) {
189- // Failed to fetch tree - skip for now
190- unchanged ++ ;
191- if ( i % 50 === 0 ) {
192- console . log ( ` ${ progress } Unchanged: ${ repo . full_name } (status ${ status } , tree fetch failed)` ) ;
193+ if ( hasScaffoldConfig ( tree ) ) {
194+ if ( repo . deleted_at !== null ) {
195+ await updateDeletedAt ( repo . id , null ) ;
196+ restored ++ ;
197+ console . log ( ` ${ progress } Restored: ${ repo . full_name } (status ${ status } )` ) ;
198+ } else {
199+ unchanged ++ ;
200+ if ( i % 50 === 0 ) {
201+ console . log ( ` ${ progress } Unchanged: ${ repo . full_name } (status ${ status } )` ) ;
202+ }
193203 }
194- } else if ( ! tree . truncated && ! hasScaffoldConfig ( tree ) ) {
195- // scaffold.config.ts not found and tree is not truncated
196- await updateDeletedAt ( repo . id , "now" ) ;
197- markedDeleted ++ ;
198- deletedNoScaffoldConfig ++ ;
199- console . log (
200- `${ progress } Marked deleted (no scaffold.config.ts): ${ repo . full_name } (status ${ status } )`
201- ) ;
202204 } else {
203- unchanged ++ ;
204- if ( i % 50 === 0 ) {
205- console . log ( `${ progress } Unchanged: ${ repo . full_name } (status ${ status } )` ) ;
205+ if ( repo . deleted_at === null ) {
206+ await updateDeletedAt ( repo . id , "now" ) ;
207+ markedDeleted ++ ;
208+ deletedNoScaffoldConfig ++ ;
209+ console . log ( `${ progress } Marked deleted because no scaffold.config.ts: ${ repo . full_name } (status ${ status } )` ) ;
210+ } else {
211+ unchanged ++ ;
212+ if ( i % 50 === 0 ) {
213+ console . log ( `${ progress } Unchanged: ${ repo . full_name } (status ${ status } )` ) ;
214+ }
206215 }
207216 }
208-
209- // Additional delay after git tree API call
210- await delay ( 150 ) ;
211- }
212- } else {
213- unchanged ++ ;
214- if ( i % 50 === 0 ) {
215- console . log ( `${ progress } Unchanged: ${ repo . full_name } (status ${ status } )` ) ;
216217 }
217218 }
218219
0 commit comments