Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -14,7 +14,7 @@ repos:
hooks:
- id: pyupgrade
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.2
rev: v0.12.11
hooks:
- id: ruff
- id: ruff-format
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Add this configuration to your `.pre-commit-config.yaml` file:
```yaml
repos:
- repo: https://github.com/cpp-linter/cpp-linter-hooks
rev: v1.0.1 # Use the tag or commit you want
rev: v1.1.0 # Use the tag or commit you want
hooks:
- id: clang-format
args: [--style=Google] # Other coding style: LLVM, GNU, Chromium, Microsoft, Mozilla, WebKit.
Expand All @@ -46,7 +46,7 @@ To use custom configurations like `.clang-format` and `.clang-tidy`:
```yaml
repos:
- repo: https://github.com/cpp-linter/cpp-linter-hooks
rev: v1.0.1
rev: v1.1.0
hooks:
- id: clang-format
args: [--style=file] # Loads style from .clang-format file
Expand All @@ -61,7 +61,7 @@ To use specific versions of clang-format and clang-tidy (using Python wheel pack
```yaml
repos:
- repo: https://github.com/cpp-linter/cpp-linter-hooks
rev: v1.0.1
rev: v1.1.0
hooks:
- id: clang-format
args: [--style=file, --version=18] # Specifies version
Expand All @@ -70,7 +70,7 @@ repos:
```

> [!NOTE]
> Starting from version v1.0.0, this package uses Python wheel packages ([clang-format](https://pypi.org/project/clang-format/) and [clang-tidy](https://pypi.org/project/clang-tidy/)) instead of the previous clang-tools binaries. The wheel packages provide better cross-platform compatibility and easier installation. For more details, see the [Migration Guide](MIGRATION.md).
> Starting from version v1.0.0, this pre-commit hook uses Python wheel packages ([clang-format](https://pypi.org/project/clang-format/) and [clang-tidy](https://pypi.org/project/clang-tidy/)) instead of the previous clang-tools binaries. The wheel packages provide better cross-platform compatibility and easier installation. For more details, see the [Migration Guide](MIGRATION.md).

## Output

Expand Down Expand Up @@ -147,11 +147,11 @@ Use -header-filter=.* to display errors from all non-system headers. Use -system
### Performance Optimization

> [!TIP]
> If your `pre-commit` runs longer than expected, it is highly recommended to add `files` in `.pre-commit-config.yaml` to limit the scope of the hook. This helps improve performance by reducing the number of files being checked and avoids unnecessary processing. Here's an example configuration:
> For large codebases, if your `pre-commit` runs longer than expected, it is highly recommended to add `files` in `.pre-commit-config.yaml` to limit the scope of the hook. This helps improve performance by reducing the number of files being checked and avoids unnecessary processing. Here's an example configuration:

```yaml
- repo: https://github.com/cpp-linter/cpp-linter-hooks
rev: v1.0.1
rev: v1.1.0
hooks:
- id: clang-format
args: [--style=file, --version=18]
Expand All @@ -177,7 +177,7 @@ This approach ensures that only modified files are checked, further speeding up
```yaml
repos:
- repo: https://github.com/cpp-linter/cpp-linter-hooks
rev: v1.0.1
rev: v1.1.0
hooks:
- id: clang-format
args: [--style=file, --version=18, --verbose] # Add -v or --verbose for detailed output
Expand Down
3 changes: 2 additions & 1 deletion cpp_linter_hooks/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def get_version_from_dependency(tool: str) -> Optional[str]:
"20.1.4",
"20.1.5",
"20.1.6",
"20.1.7",
"20.1.8",
"21.1.0",
]

CLANG_TIDY_VERSIONS = [
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ tracker = "https://github.com/cpp-linter/cpp-linter-hooks/issues"
[project.optional-dependencies]
# only clang tools can added to this section to make hooks work
tools = [
"clang-format==20.1.7",
"clang-format==21.1.0",
"clang-tidy==20.1.0",
]

Expand Down
2 changes: 2 additions & 0 deletions tests/test_clang_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
(["--style=Google", "--version=18"], (0, "")),
(["--style=Google", "--version=19"], (0, "")),
(["--style=Google", "--version=20"], (0, "")),
(["--style=Google", "--version=21"], (0, "")),
),
)
def test_run_clang_format_valid(args, expected_retval, tmp_path):
Expand All @@ -40,6 +41,7 @@ def test_run_clang_format_valid(args, expected_retval, tmp_path):
(["--style=Google", "--version=18"], 1),
(["--style=Google", "--version=19"], 1),
(["--style=Google", "--version=20"], 1),
(["--style=Google", "--version=21"], 1),
),
)
def test_run_clang_format_invalid(args, expected_retval, tmp_path):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_clang_tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def generate_compilation_database():
(['--checks="boost-*"', "--version=18"], 1),
(['--checks="boost-*"', "--version=19"], 1),
(['--checks="boost-*"', "--version=20"], 1),
(['--checks="boost-*"', "--version=21"], 1),
),
)
def test_run_clang_tidy_valid(args, expected_retval):
Expand All @@ -43,6 +44,7 @@ def test_run_clang_tidy_valid(args, expected_retval):
(['--checks="boost-*"', "--version=18"], 1),
(['--checks="boost-*"', "--version=19"], 1),
(['--checks="boost-*"', "--version=20"], 1),
(['--checks="boost-*"', "--version=21"], 1),
),
)
def test_run_clang_tidy_invalid(args, expected_retval, tmp_path):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ def test_get_version_from_dependency_malformed_toml():
"user_input,expected",
[
(None, None),
("20", "20.1.7"), # Should find latest 20.x
("20.1", "20.1.7"), # Should find latest 20.1.x
("20", "20.1.8"), # Should find latest 20.x
("20.1", "20.1.8"), # Should find latest 20.1.x
("20.1.7", "20.1.7"), # Exact match
("18", "18.1.8"), # Should find latest 18.x
("18.1", "18.1.8"), # Should find latest 18.1.x
Expand Down
Loading