MCPcopy Create free account
hub / github.com/anthropics/claude-code / backfillDuplicateComments

Function backfillDuplicateComments

scripts/backfill-duplicate-comments.ts:72–208  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70}
71
72async function backfillDuplicateComments(): Promise<void> {
73 console.log("[DEBUG] Starting backfill duplicate comments script");
74
75 const token = process.env.GITHUB_TOKEN;
76 if (!token) {
77 throw new Error(`GITHUB_TOKEN environment variable is required
78
79Usage:
80 GITHUB_TOKEN=your_token bun run scripts/backfill-duplicate-comments.ts
81
82Environment Variables:
83 GITHUB_TOKEN - GitHub personal access token with repo and actions permissions (required)
84 DRY_RUN - Set to "false" to actually trigger workflows (default: true for safety)
85 MAX_ISSUE_NUMBER - Only process issues with numbers less than this value (default: 4050)`);
86 }
87 console.log("[DEBUG] GitHub token found");
88
89 const owner = "anthropics";
90 const repo = "claude-code";
91 const dryRun = process.env.DRY_RUN !== "false";
92 const maxIssueNumber = parseInt(process.env.MAX_ISSUE_NUMBER || "4050", 10);
93 const minIssueNumber = parseInt(process.env.MIN_ISSUE_NUMBER || "1", 10);
94
95 console.log(`[DEBUG] Repository: ${owner}/${repo}`);
96 console.log(`[DEBUG] Dry run mode: ${dryRun}`);
97 console.log(`[DEBUG] Looking at issues between #${minIssueNumber} and #${maxIssueNumber}`);
98
99 console.log(`[DEBUG] Fetching issues between #${minIssueNumber} and #${maxIssueNumber}...`);
100 const allIssues: GitHubIssue[] = [];
101 let page = 1;
102 const perPage = 100;
103
104 while (true) {
105 const pageIssues: GitHubIssue[] = await githubRequest(
106 `/repos/${owner}/${repo}/issues?state=all&per_page=${perPage}&page=${page}&sort=created&direction=desc`,
107 token
108 );
109
110 if (pageIssues.length === 0) break;
111
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

Callers 1

Calls 2

triggerDedupeWorkflowFunction · 0.85
githubRequestFunction · 0.70

Tested by

no test coverage detected