Browse Source

Merge topic 'pre-commit-version-bump-typos-hook'

15d558016c pre-commit: change the repo and version bump `typos` hook

Acked-by: Kitware Robot <[email protected]>
Merge-request: !10904
Brad King 8 months ago
parent
commit
3ae807ffbb
3 changed files with 39 additions and 26 deletions
  1. 5 3
      .pre-commit-config.yaml
  2. 29 19
      .typos.toml
  3. 5 4
      Source/cmGeneratorTarget_Sources.cxx

+ 5 - 3
.pre-commit-config.yaml

@@ -39,6 +39,7 @@ repos:
                 CMakeLib/testCTestResourceSpec_data/spec13
               | RunCMake/CTestResourceAllocation/invalid
               )\.json
+      - id: check-toml
       - id: check-yaml
       - id: end-of-file-fixer
         # NOTE Exclude tests directory: some test files have no
@@ -102,13 +103,14 @@ repos:
       - id: rst-inline-touching-normal
 
   - repo: https://github.com/codespell-project/codespell
-    rev: v2.4.0
+    rev: v2.4.1
     hooks:
       - id: codespell
         stages: [commit-msg, pre-commit]
 
-  - repo: https://github.com/crate-ci/typos
-    rev: v1.30.0
+    # NOTE See BUG https://github.com/crate-ci/typos/issues/390
+  - repo: https://github.com/adhtruong/mirrors-typos
+    rev: v1.33.1
     hooks:
       - id: typos
         # NOTE Override hook's default args to prevent automatic

+ 29 - 19
.typos.toml

@@ -5,10 +5,10 @@
 check-file = true
 check-filename = true
 extend-ignore-re = [
-    # NOTE Allow to mark a block of text to exclude from spellchecking
-    "(?s)(#|/(/|\\*)|\\.\\.)\\s*(NOQA|noqa):? spellcheck(: *|=| +)off.*?\\n\\s*(#|/(/|\\*)|\\.\\.)\\s*(NOQA|noqa):? spellcheck(: *|=| +)on"
+    # NOTE Allow to mark block of text to exclude from spellchecking inside C++ or hash-style comments (CMake,Python,&etc.)
+    "(?s)(#|//)\\s*(NOQA|noqa):? spellcheck(: *|=| +)off.*?\\n\\s*(#|//)\\s*(NOQA|noqa):? spellcheck(: *|=| +)on"
     # NOTE Allow to mark a line to exclude from spellchecking
-  , "(?Rm)^.*(#|/(/|\\*)|\\.\\.)\\s*(NOQA|noqa):? spellcheck(: *|=| +)disable-line$"
+  , "(?Rm)^.*(#|//)\\s*(NOQA|noqa):? spellcheck(: *|=| +)disable-line$"
     # NOTE Stop checking from this line to the end of file
     # This line is a marker added by Git to the `COMMIT_EDITMSG`.
   , "(?sm)^# ------------------------ >8 ------------------------$.*"
@@ -34,7 +34,28 @@ ser = "ser"
 restat = "restat"
 # SpectreMitigation
 Spectre = "Spectre"
+# Identifier used in source code (`GlobalTargetInfo`)
+gti = "gti"
 
+[files]
+ignore-hidden = false
+ignore-dot = false
+extend-exclude = [
+    "CONTRIBUTORS.rst"
+    # Exclude third-party sources.
+  , "Source/CursesDialog/form/"
+  , "Source/kwsys/"
+  , "Source/bindexplib.cxx"
+  , "Source/cmcldeps.cxx"
+  , "Source/QtDialog/*.ui"
+  , "Utilities/cm*"
+  , "Utilities/ClangTidyModule"
+  , "Utilities/KWIML"
+    # FIXME: Fix spelling typos in tests.  Exclude for now.
+  , "Tests"
+  ]
+
+# BEGIN Type-specific settings
 [type.cmake.extend-identifiers]
 COMMANDs = "COMMANDs"
 xCOMMANDx = "xCOMMANDx"
@@ -60,20 +81,9 @@ SEH = "SEH"
 [type.py.extend-identifiers]
 typ = "typ"
 
-[files]
-ignore-hidden = false
-ignore-dot = false
-extend-exclude = [
-    "CONTRIBUTORS.rst"
-    # Exclude third-party sources.
-  , "Source/CursesDialog/form/"
-  , "Source/kwsys/"
-  , "Source/bindexplib.cxx"
-  , "Source/cmcldeps.cxx"
-  , "Source/QtDialog/*.ui"
-  , "Utilities/cm*"
-  , "Utilities/ClangTidyModule"
-  , "Utilities/KWIML"
-    # FIXME: Fix spelling typos in tests.  Exclude for now.
-  , "Tests"
+[type.rst]
+extend-ignore-re = [
+    # NOTE Allow to mark block of text to exclude from spellchecking as RST comments
+    "(?s)\\.\\.\\s+(NOQA|noqa):? spellcheck(: *|=| +)off.*?\\n\\.\\.\\s+(NOQA|noqa):? spellcheck(: *|=| +)on"
   ]
+# END Type-specific settings

+ 5 - 4
Source/cmGeneratorTarget_Sources.cxx

@@ -96,10 +96,11 @@ void addFileSetEntry(cmGeneratorTarget const* headTarget,
   }
   cmake* cm = headTarget->GetLocalGenerator()->GetCMakeInstance();
   for (auto& entryCge : fileSet->CompileFileEntries()) {
-    auto tpe = cmGeneratorTarget::TargetPropertyEntry::CreateFileSet(
-      dirs, contextSensitiveDirs, std::move(entryCge), fileSet);
-    entries.Entries.emplace_back(
-      EvaluateTargetPropertyEntry(headTarget, config, "", dagChecker, *tpe));
+    auto targetPropEntry =
+      cmGeneratorTarget::TargetPropertyEntry::CreateFileSet(
+        dirs, contextSensitiveDirs, std::move(entryCge), fileSet);
+    entries.Entries.emplace_back(EvaluateTargetPropertyEntry(
+      headTarget, config, "", dagChecker, *targetPropEntry));
     EvaluatedTargetPropertyEntry const& entry = entries.Entries.back();
     for (auto const& file : entry.Values) {
       auto* sf = headTarget->Makefile->GetOrCreateSource(file);