From e144f706214298b04cab8749f1b97fea74b3ea69 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Apr 2026 08:54:30 +0000 Subject: [PATCH 1/3] Bump the pre-commit-hooks group with 3 updates Bumps the pre-commit-hooks group with 3 updates: [https://github.com/astral-sh/ruff-pre-commit](https://github.com/astral-sh/ruff-pre-commit), [https://github.com/asottile/pyupgrade](https://github.com/asottile/pyupgrade) and [https://github.com/BlankSpruce/gersemi-pre-commit](https://github.com/BlankSpruce/gersemi-pre-commit). Updates `https://github.com/astral-sh/ruff-pre-commit` from v0.9.9 to 0.15.12 - [Release notes](https://github.com/astral-sh/ruff-pre-commit/releases) - [Commits](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.9...v0.15.12) Updates `https://github.com/asottile/pyupgrade` from v3.9.0 to 3.21.2 - [Commits](https://github.com/asottile/pyupgrade/compare/v3.9.0...v3.21.2) Updates `https://github.com/BlankSpruce/gersemi-pre-commit` from 0.27.2 to 0.9999.0 - [Commits](https://github.com/BlankSpruce/gersemi-pre-commit/compare/0.27.2...0.9999.0) --- updated-dependencies: - dependency-name: https://github.com/astral-sh/ruff-pre-commit dependency-version: 0.15.12 dependency-type: direct:production dependency-group: pre-commit-hooks - dependency-name: https://github.com/asottile/pyupgrade dependency-version: 3.21.2 dependency-type: direct:production dependency-group: pre-commit-hooks - dependency-name: https://github.com/BlankSpruce/gersemi-pre-commit dependency-version: 0.9999.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: pre-commit-hooks ... Signed-off-by: dependabot[bot] --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 520cd2b..0ac0747 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,20 +30,20 @@ repos: # Python linting and formatting - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.9.9 + rev: v0.15.12 hooks: - id: ruff - id: ruff-format - repo: https://github.com/asottile/pyupgrade - rev: v3.9.0 + rev: v3.21.2 hooks: - id: pyupgrade args: [--py310-plus] # CMake linting and formatting - repo: https://github.com/BlankSpruce/gersemi-pre-commit - rev: 0.27.2 + rev: 0.9999.0 hooks: - id: gersemi name: CMake linting From b4a6334f0cbc0ec5811364a84f69c5f555ccad9a Mon Sep 17 00:00:00 2001 From: MarkusB <> Date: Wed, 29 Apr 2026 11:00:40 +0200 Subject: [PATCH 2/3] up --- configs/v4/.pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configs/v4/.pre-commit-config.yaml b/configs/v4/.pre-commit-config.yaml index 520cd2b..0ac0747 100644 --- a/configs/v4/.pre-commit-config.yaml +++ b/configs/v4/.pre-commit-config.yaml @@ -30,20 +30,20 @@ repos: # Python linting and formatting - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.9.9 + rev: v0.15.12 hooks: - id: ruff - id: ruff-format - repo: https://github.com/asottile/pyupgrade - rev: v3.9.0 + rev: v3.21.2 hooks: - id: pyupgrade args: [--py310-plus] # CMake linting and formatting - repo: https://github.com/BlankSpruce/gersemi-pre-commit - rev: 0.27.2 + rev: 0.9999.0 hooks: - id: gersemi name: CMake linting From 0ad5b11429c2b71d69933f01e97716c5f9e8db39 Mon Sep 17 00:00:00 2001 From: MarkusB <> Date: Wed, 29 Apr 2026 16:50:33 +0200 Subject: [PATCH 3/3] symlink pre-commit config --- .github/dependabot.yml | 2 +- .pre-commit-config.yaml | 59 +----------------------------- README.md | 7 ++-- configs/v4/.pre-commit-config.yaml | 2 +- python/mb-pre-commit-setup.py | 10 ++++- 5 files changed, 15 insertions(+), 65 deletions(-) mode change 100644 => 120000 .pre-commit-config.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b264010..6e1a371 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -10,7 +10,7 @@ updates: - "*" - package-ecosystem: pre-commit - directory: / + directory: /configs/v4 schedule: interval: weekly groups: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 0ac0747..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,58 +0,0 @@ -# Example config shipped with mb-pre-commit (see configs/v4). Edit freely; CMake may refresh -# this file on configure unless you disable PRE_COMMIT_INSTALL_EXAMPLE_CONFIG. -# https://pre-commit.com/ -minimum_pre_commit_version: '4.0.0' -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v6.0.0 - hooks: - - id: check-added-large-files - - id: check-case-conflict - - id: check-json - - id: check-merge-conflict - - id: check-symlinks - - id: check-yaml - - id: end-of-file-fixer - - id: mixed-line-ending - - id: trailing-whitespace - - # Markdown linting - # Config file: .markdownlint.yaml - - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.48.0 - hooks: - - id: markdownlint - - - repo: https://github.com/codespell-project/codespell - rev: v2.4.2 - hooks: - - id: codespell - - # Python linting and formatting - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.12 - hooks: - - id: ruff - - id: ruff-format - - - repo: https://github.com/asottile/pyupgrade - rev: v3.21.2 - hooks: - - id: pyupgrade - args: [--py310-plus] - - # CMake linting and formatting - - repo: https://github.com/BlankSpruce/gersemi-pre-commit - rev: 0.9999.0 - hooks: - - id: gersemi - name: CMake linting - - # Clang-format for C++ - # This brings in a portable version of clang-format. - # See also: https://github.com/ssciwr/clang-format-wheel - - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v22.1.4 - hooks: - - id: clang-format - types_or: [c++, c] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 120000 index 0000000..ab70426 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1 @@ +configs/v4/.pre-commit-config.yaml \ No newline at end of file diff --git a/README.md b/README.md index fbc539a..9ae94ce 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,7 @@ This project’s CMake module uses APIs that require **CMake 3.21+** (`file(COPY | `PRE_COMMIT_MODE` | `CUSTOM` | `CUSTOM` or `NATIVE` (see below). | | `PRE_COMMIT_VERSION` | `4.5.1` | Exact `pre-commit` version installed in the venv via pip. | | `PRE_COMMIT_VENV_DIR` | `${PROJECT_SOURCE_DIR}/.venv` | Virtualenv path; `Scripts/python.exe` on Windows, `bin/python3` otherwise. | -| `PRE_COMMIT_INSTALL_EXAMPLE_CONFIG` | `ON` | When `ON`, copies the best matching `configs/vN/.pre-commit-config.yaml` to `${PROJECT_SOURCE_DIR}/.pre-commit-config.yaml` on each configure (overwrites). | +| `PRE_COMMIT_INSTALL_EXAMPLE_CONFIG` | `ON` | When `ON`, refreshes `.pre-commit-config.yaml` from the best matching `configs/vN/...` on configure; skipped if unchanged. | | `PRE_COMMIT_SWEEP_TARGET` | `mb-pre-commit-sweep` | Name of the `add_custom_target` that runs `pre-commit run --all-files`. Set to `OFF` to skip. If the default name is taken, the target is `mb_pre_commit_sweep` instead. | | `PRE_COMMIT_TOOL_SWEEP_TARGET` | `*(unset)*` | Second sweep at this package root when `PROJECT_SOURCE_DIR` is elsewhere; same venv. If it matches the main sweep tree, ignored. Omit/`OFF`: none. | @@ -203,8 +203,9 @@ venv. You get upstream’s installed hook and default behavior instead of the cu ## Contributing and releases The canonical example hook list for packaging is [`configs/v4/.pre-commit-config.yaml`](configs/v4/.pre-commit-config.yaml). -The copy at the repository root is kept **byte-identical** (CI fails on drift) so local `pre-commit` runs and packaged -configs stay aligned; edit `configs/v4/` first, then sync the root file. +In **this** repository, the root [`.pre-commit-config.yaml`](.pre-commit-config.yaml) is a **symlink** to that file so +Dependabot (configured for `configs/v4`) and local `pre-commit` stay aligned; CI still runs `cmp` against the resolved +content. **Consumer projects** still get a normal file copy from CMake. Edit `configs/v4/` only. Maintainers can create an annotated release tag and push it to `origin` with [`scripts/git-tag`](scripts/git-tag): it refuses a dirty working tree or an existing tag, then runs `git tag -a` with message `Release ` and `git push diff --git a/configs/v4/.pre-commit-config.yaml b/configs/v4/.pre-commit-config.yaml index 0ac0747..9b98775 100644 --- a/configs/v4/.pre-commit-config.yaml +++ b/configs/v4/.pre-commit-config.yaml @@ -43,7 +43,7 @@ repos: # CMake linting and formatting - repo: https://github.com/BlankSpruce/gersemi-pre-commit - rev: 0.9999.0 + rev: 0.27.2 hooks: - id: gersemi name: CMake linting diff --git a/python/mb-pre-commit-setup.py b/python/mb-pre-commit-setup.py index eee0615..fbf7827 100644 --- a/python/mb-pre-commit-setup.py +++ b/python/mb-pre-commit-setup.py @@ -511,8 +511,14 @@ def _install_example_configs( return best_n, best_src = picked dest = project_source / ".pre-commit-config.yaml" - shutil.copyfile(best_src, dest) - _status(f"Installed example pre-commit config (configs/v{best_n}) -> {dest}") + if dest.exists() and dest.samefile(best_src): + _status( + f"Example pre-commit config already present at {dest} " + f"(same file as {best_src}); skipping copy" + ) + else: + shutil.copyfile(best_src, dest) + _status(f"Installed example pre-commit config (configs/v{best_n}) -> {dest}") md_src = best_src.parent / ".markdownlint.yaml" if md_src.is_file(): md_dest = project_source / ".markdownlint.yaml"