Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 41 additions & 40 deletions packages/scripts/src/check-repo-online.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,54 +165,55 @@ async function main() {
const res = await headWithRetry(repo.url);
const status = res.status;

const isOnline = status >= 200 && status < 400; // treat 2xx/3xx as online
const isNotFound = status === 404;

if (isNotFound && repo.deleted_at === null) {
await updateDeletedAt(repo.id, "now");
markedDeleted++;
console.log(`${progress} Marked deleted: ${repo.full_name} (status ${status})`);
} else if (isOnline) {
if (isNotFound) {
if (repo.deleted_at === null) {
await updateDeletedAt(repo.id, "now");
markedDeleted++;
console.log(`${progress} Marked deleted: ${repo.full_name} (status ${status})`);
} else {
unchanged++;
if (i % 50 === 0) {
console.log(`${progress} Unchanged: ${repo.full_name} (status ${status})`);
}
}
} else {
// Repository is online - check if it still uses Scaffold-ETH 2
if (repo.deleted_at !== null) {
// Repository was previously marked as deleted but is now online
await updateDeletedAt(repo.id, null);
restored++;
console.log(`${progress} Restored: ${repo.full_name} (status ${status})`);
const branch = repo.default_branch || "main";
const tree = await fetchGitTreeWithRetry(repo.full_name, branch);

if (tree === null || tree.truncated) {
// Failed to fetch tree or tree is truncated - skip for now
unchanged++;
if (i % 50 === 0) {
console.log(`${progress} Unchanged: ${repo.full_name} (status ${status}, tree fetch failed)`);
}
} else {
// Check if scaffold.config.ts exists
// Use "main" as fallback if default_branch is null
const branch = repo.default_branch || "main";
const tree = await fetchGitTreeWithRetry(repo.full_name, branch);

if (tree === null) {
// Failed to fetch tree - skip for now
unchanged++;
if (i % 50 === 0) {
console.log(`${progress} Unchanged: ${repo.full_name} (status ${status}, tree fetch failed)`);
if (hasScaffoldConfig(tree)) {
if (repo.deleted_at !== null) {
await updateDeletedAt(repo.id, null);
restored++;
console.log(`${progress} Restored: ${repo.full_name} (status ${status})`);
} else {
unchanged++;
if (i % 50 === 0) {
console.log(`${progress} Unchanged: ${repo.full_name} (status ${status})`);
}
}
} else if (!tree.truncated && !hasScaffoldConfig(tree)) {
// scaffold.config.ts not found and tree is not truncated
await updateDeletedAt(repo.id, "now");
markedDeleted++;
deletedNoScaffoldConfig++;
console.log(
`${progress} Marked deleted (no scaffold.config.ts): ${repo.full_name} (status ${status})`
);
} else {
unchanged++;
if (i % 50 === 0) {
console.log(`${progress} Unchanged: ${repo.full_name} (status ${status})`);
if (repo.deleted_at === null) {
await updateDeletedAt(repo.id, "now");
markedDeleted++;
deletedNoScaffoldConfig++;
console.log(`${progress} Marked deleted because no scaffold.config.ts: ${repo.full_name} (status ${status})`);
} else {
unchanged++;
if (i % 50 === 0) {
console.log(`${progress} Unchanged: ${repo.full_name} (status ${status})`);
}
}
}

// Additional delay after git tree API call
await delay(150);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleting this will give us API limit problems, or it's fine?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is another delay below

}
} else {
unchanged++;
if (i % 50 === 0) {
console.log(`${progress} Unchanged: ${repo.full_name} (status ${status})`);
}
}

Expand Down