Skip to content

Commit 8a02308

Browse files
heiskrCopilot
andauthored
Fix link check workflow failures (#59963)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b807b04 commit 8a02308

4 files changed

Lines changed: 31 additions & 5 deletions

File tree

.github/workflows/link-check-internal.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ jobs:
108108
needs: [setup-matrix, check-internal-links]
109109
runs-on: ubuntu-latest
110110
permissions:
111+
contents: read
111112
issues: write
112113
steps:
113114
- name: Checkout

content/copilot/responsible-use/copilot-in-github-desktop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The feature is intended to supplement rather than replace a human's work to draf
3939

4040
### Provide feedback
4141

42-
If you encounter any issues or limitations with {% data variables.copilot.copilot_desktop_short %}, you can provide feedback by creating an issue in the [{% data variables.product.prodname_desktop %} open source repository](https://github.com/desktop/desktop/issues/new?template=bug_report.yaml ). This can help the developers to improve the tool and address any concerns or limitations.
42+
If you encounter any issues or limitations with {% data variables.copilot.copilot_desktop_short %}, you can provide feedback by creating an issue in the [{% data variables.product.prodname_desktop %} open source repository](https://github.com/desktop/desktop/issues/new?template=bug_report.yaml). This can help the developers to improve the tool and address any concerns or limitations.
4343

4444
## Limitations of {% data variables.copilot.copilot_desktop_short %}
4545

src/links/lib/extract-links.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ import type { Context, Page } from '@/types'
1616
// Link patterns for Markdown
1717
const INTERNAL_LINK_PATTERN = /\]\(\/[^)]+\)/g
1818
const AUTOTITLE_LINK_PATTERN = /\[AUTOTITLE\]\(([^)]+)\)/g
19-
// Handles one level of balanced parentheses in URLs (e.g., Wikipedia links)
20-
const EXTERNAL_LINK_PATTERN = /\]\((https?:\/\/(?:[^()\s]+|\([^()]*\))*)\)/g
19+
// Handles one level of balanced parentheses in URLs (e.g., Wikipedia links).
20+
// Uses an unrolled loop to avoid catastrophic backtracking on malformed URLs.
21+
const EXTERNAL_LINK_PATTERN = /\]\((https?:\/\/[^()\s]*(?:\([^()]*\)[^()\s]*)*)\)/g
2122
const IMAGE_LINK_PATTERN = /!\[[^\]]*\]\(([^)]+)\)/g
2223

2324
// Anchor link patterns (for same-page links)

src/links/scripts/check-links-external.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,20 @@ async function extractAllExternalLinks(): Promise<Map<string, { file: string; li
155155

156156
// Find all Markdown files
157157
const files = await glob('content/**/*.md')
158+
console.log(`Found ${files.length} Markdown files to scan`)
158159

159-
for (const file of files) {
160+
const extractStart = Date.now()
161+
for (let i = 0; i < files.length; i++) {
162+
const file = files[i]
163+
const fileStart = Date.now()
160164
const content = fs.readFileSync(file, 'utf-8')
161165
const result = extractLinksFromMarkdown(content)
166+
const fileMs = Date.now() - fileStart
167+
168+
// Warn if a single file takes longer than 1 second (possible regex issue)
169+
if (fileMs > 1000) {
170+
console.warn(` ⚠️ Slow extraction: ${file} took ${(fileMs / 1000).toFixed(1)}s`)
171+
}
162172

163173
for (const link of result.externalLinks) {
164174
// Only check HTTPS links
@@ -173,8 +183,16 @@ async function extractAllExternalLinks(): Promise<Map<string, { file: string; li
173183
}
174184
links.get(url)!.push({ file, line: link.line })
175185
}
186+
187+
if ((i + 1) % 500 === 0) {
188+
const elapsed = ((Date.now() - extractStart) / 1000).toFixed(0)
189+
console.log(` Scanned ${i + 1}/${files.length} files (${elapsed}s elapsed)`)
190+
}
176191
}
177192

193+
const totalElapsed = ((Date.now() - extractStart) / 1000).toFixed(1)
194+
console.log(`Extraction complete in ${totalElapsed}s`)
195+
178196
return links
179197
}
180198

@@ -275,7 +293,13 @@ async function main() {
275293

276294
// Progress update every 100 URLs
277295
if (checkedCount % 100 === 0) {
278-
console.log(` Checked ${checkedCount}/${maxUrls} URLs...`)
296+
const elapsed = ((Date.now() - startTime) / 1000).toFixed(0)
297+
const rate = (checkedCount / (Date.now() - startTime)) * 1000 * 60
298+
const remaining = maxUrls - checkedCount
299+
const etaMin = (remaining / rate).toFixed(0)
300+
console.log(
301+
` Checked ${checkedCount}/${maxUrls} URLs (${cachedCount} cached) — ${elapsed}s elapsed, ~${etaMin}m remaining`,
302+
)
279303
}
280304

281305
// Small delay between non-cached requests to avoid rate limiting

0 commit comments

Comments
 (0)