spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

Merge pull request #5881 from anthropics/boris/iuniBrowse files
feat: update dedupe backfill script to filter by issue number
Boris Cherny authored on Aug 28, 2025 · GitHub committed on Aug 28, 2025 parents 786259a + 20ba9a3 · commit dc8f77c7efcd
1 changed file+26 -11compared with 786259a
Mscripts/backfill-duplicate-comments.ts
@@ -82,46 +82,61 @@
8282 Environment Variables:
8383 GITHUB_TOKEN - GitHub personal access token with repo and actions permissions (required)
8484 DRY_RUN - Set to "false" to actually trigger workflows (default: true for safety)
85- DAYS_BACK - How many days back to look for old issues (default: 90)`);
85+ MAX_ISSUE_NUMBER - Only process issues with numbers less than this value (default: 4050)`);
8686 }
8787 console.log("[DEBUG] GitHub token found");
8888
8989 const owner = "anthropics";
9090 const repo = "claude-code";
9191 const dryRun = process.env.DRY_RUN !== "false";
92- const daysBack = parseInt(process.env.DAYS_BACK || "90", 10);
92+ const maxIssueNumber = parseInt(process.env.MAX_ISSUE_NUMBER || "4050", 10);
93+ const minIssueNumber = parseInt(process.env.MIN_ISSUE_NUMBER || "1", 10);
9394
9495 console.log(`[DEBUG] Repository: ${owner}/${repo}`);
9596 console.log(`[DEBUG] Dry run mode: ${dryRun}`);
96- console.log(`[DEBUG] Looking back ${daysBack} days`);
97+ console.log(`[DEBUG] Looking at issues between #${minIssueNumber} and #${maxIssueNumber}`);
9798
98- const cutoffDate = new Date();
99- cutoffDate.setDate(cutoffDate.getDate() - daysBack);
100-
101- console.log(`[DEBUG] Fetching issues created since ${cutoffDate.toISOString()}...`);
99+ console.log(`[DEBUG] Fetching issues between #${minIssueNumber} and #${maxIssueNumber}...`);
102100 const allIssues: GitHubIssue[] = [];
103101 let page = 1;
104102 const perPage = 100;
105103
106104 while (true) {
107105 const pageIssues: GitHubIssue[] = await githubRequest(
108- `/repos/${owner}/${repo}/issues?state=all&per_page=${perPage}&page=${page}&since=${cutoffDate.toISOString()}`,
106+ `/repos/${owner}/${repo}/issues?state=all&per_page=${perPage}&page=${page}&sort=created&direction=desc`,
109107 token
110108 );
111109
112110 if (pageIssues.length === 0) break;
113111
114- allIssues.push(...pageIssues);
112+ // Filter to only include issues within the specified range
113+ const filteredIssues = pageIssues.filter(issue =>
114+ issue.number >= minIssueNumber && issue.number < maxIssueNumber
115+ );
116+ allIssues.push(...filteredIssues);
117+
118+ // If the oldest issue in this page is still above our minimum, we need to continue
119+ // but if the oldest issue is below our minimum, we can stop
120+ const oldestIssueInPage = pageIssues[pageIssues.length - 1];
121+ if (oldestIssueInPage && oldestIssueInPage.number >= maxIssueNumber) {
122+ console.log(`[DEBUG] Oldest issue in page #${page} is #${oldestIssueInPage.number}, continuing...`);
123+ } else if (oldestIssueInPage && oldestIssueInPage.number < minIssueNumber) {
124+ console.log(`[DEBUG] Oldest issue in page #${page} is #${oldestIssueInPage.number}, below minimum, stopping`);
125+ break;
126+ } else if (filteredIssues.length === 0 && pageIssues.length > 0) {
127+ console.log(`[DEBUG] No issues in page #${page} are in range #${minIssueNumber}-#${maxIssueNumber}, continuing...`);
128+ }
129+
115130 page++;
116131
117132 // Safety limit to avoid infinite loops
118- if (page > 100) {
133+ if (page > 200) {
119134 console.log("[DEBUG] Reached page limit, stopping pagination");
120135 break;
121136 }
122137 }
123138
124- console.log(`[DEBUG] Found ${allIssues.length} issues from the last ${daysBack} days`);
139+ console.log(`[DEBUG] Found ${allIssues.length} issues between #${minIssueNumber} and #${maxIssueNumber}`);
125140
126141 let processedCount = 0;
127142 let candidateCount = 0;