Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ updates:
- "*"

- package-ecosystem: pre-commit
directory: /
directory: /configs/v4
schedule:
interval: weekly
groups:
Expand Down
58 changes: 0 additions & 58 deletions .pre-commit-config.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .pre-commit-config.yaml
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |

Expand Down Expand Up @@ -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 <tag>` and `git push
Expand Down
4 changes: 2 additions & 2 deletions configs/v4/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ 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]
Expand Down
10 changes: 8 additions & 2 deletions python/mb-pre-commit-setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading