From c1cb034c7c9a4cf9211593af4703e2b69f478ed3 Mon Sep 17 00:00:00 2001 From: Felix Schindler <107669806+ftschindler@users.noreply.github.com> Date: Wed, 14 Oct 2026 17:41:54 +0200 Subject: [PATCH 1/2] Check links in the files being committed, not the whole bundle The hook moves to ftschindler/linkspector-pre-commit, which wraps linkspector so it reads the file list pre-commit passes. One rev replaces the two additional_dependencies, because the linkspector and puppeteer pair is pinned in that repository and checked there against the Chrome it resolves. CI still runs prek with --all-files, which hands the hook every markdown file, so the full sweep is unchanged and an unrelated flaky link stops blocking a commit that touched neither. --- .pre-commit-config.yaml | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f405896..0f402f8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,28 +25,15 @@ repos: files: \.md$ args: [--disable-rules, MD046, fix] pass_filenames: true -- repo: local +# The browser and the linkspector version behind it are pinned in that +# repository as a matched pair, so one `rev` here replaces the two +# `additional_dependencies` this used to carry. The hook checks the files +# pre-commit passes it rather than the whole bundle; CI runs `--all-files`, +# which hands it everything and so remains the full sweep. +- repo: https://github.com/ftschindler/linkspector-pre-commit + rev: v0.1.0 hooks: - - id: linkspector - name: Check broken links (linkspector) - # `browsers install chrome` names no version on purpose: the pinned puppeteer - # below resolves its own, so this cannot drift from the pin the way a literal - # `chrome@...` does. It is a cheap no-op once the browser is in the cache, and - # it is what makes the check independent of whether anything downloaded a - # browser earlier - a restored hook environment, or an npm that declines to - # run puppeteer's postinstall, otherwise leaves it with no browser at all. - entry: bash -c 'puppeteer browsers install chrome && linkspector check -c .linkspector.yml' - language: node - # puppeteer is pinned exactly, not left to linkspector's own `^24.37.5`. - # It is what decides which Chrome launches: each release downloads and runs - # the revision compiled into it, so a floating range here means the browser - # resolving a link changes without anything in this repository changing. - # 24.39.1 -> Chrome 146.0.7680.76. How to choose the pair, and how to read - # the mapping out of a release: - # https://raw.githubusercontent.com/ftschindler/knowledge/staging/docs/guides/pin_the_browser_behind_a_pre_commit_link_checker.md - additional_dependencies: ['@umbrelladocs/linkspector@0.5.3', 'puppeteer@24.39.1'] - pass_filenames: false - files: \.md$ + - id: linkspector-changed # -- Python formatting + linting -- - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. From a0bf9acd24bc904f77379c092e86de070be2efbd Mon Sep 17 00:00:00 2001 From: Felix Schindler <107669806+ftschindler@users.noreply.github.com> Date: Thu, 15 Oct 2026 23:34:58 +0200 Subject: [PATCH 2/2] Freeze the link-checker hook at its tag's commit Every other repo in this config is pinned to a SHA with the tag in a `frozen:` comment, which is what `autoupdate --freeze` writes. A bare tag is mutable, so the one hook that rewrites every commit's link check was the one thing here that could change without this file changing. --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0f402f8..f01536f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,7 +31,7 @@ repos: # pre-commit passes it rather than the whole bundle; CI runs `--all-files`, # which hands it everything and so remains the full sweep. - repo: https://github.com/ftschindler/linkspector-pre-commit - rev: v0.1.0 + rev: db683f24c1df3b24e91c81271811a9e8b3ae5409 # frozen: v0.1.0 hooks: - id: linkspector-changed # -- Python formatting + linting --