From 5a1b0e35d94cb47780444eff5f1c89319cb14c4d Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Fri, 5 Apr 2024 08:16:43 -0700 Subject: [PATCH] pre-commit: add spelling check Check for any changed .rst files in the doc/ directory and run `make spelling` if any changes are detected. The files directives per hook have to be more restrictive than the global hook, so this also slightly changes the files match for the other hooks. --- .pre-commit-config.yaml | 11 ++++++++++- doc/pre-commit-spell-check | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 doc/pre-commit-spell-check diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 47e6638f..b4eb8a7a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,20 @@ -files: "(console_conf|subiquity|subiquitycore|system_setup)" +files: "(console_conf|subiquity|subiquitycore|system_setup|doc)" repos: - repo: https://github.com/psf/black rev: 23.7.0 hooks: - id: black + files: "(console_conf|subiquity|subiquitycore|system_setup)" - repo: https://github.com/pycqa/isort rev: 5.12.0 hooks: - id: isort name: isort + files: "(console_conf|subiquity|subiquitycore|system_setup)" + - repo: local + hooks: + - id: doc-spelling + name: doc-spelling + language: system + entry: bash -c "cd doc/ && ./pre-commit-spell-check" + files: "doc/.*rst" diff --git a/doc/pre-commit-spell-check b/doc/pre-commit-spell-check new file mode 100755 index 00000000..dea67a2b --- /dev/null +++ b/doc/pre-commit-spell-check @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# Setup sphinx virtual env if it's not already +if [ ! -d .sphinx/venv ]; then + make install +fi + +make spelling