Skip to content

Add pre-commit hook to run clang-format on changed files #148

@bburda

Description

@bburda

Summary

Add a pre-commit hook that automatically runs clang-format on the files changed in a commit, ensuring consistent C/C++ code formatting before code is pushed.

Proposed solution

Introduce pre-commit configuration (e.g., .pre-commit-config.yaml) in the repository.

  • Add a hook that runs clang-format only on staged/changed files (C/C++ sources and headers, e.g. *.c, *.cc, *.cpp, *.cxx, *.h, *.hpp, *.hxx).
  • Ensure the hook uses the project’s .clang-format file.
  • Document setup in README.md (e.g., pip install pre-commit && pre-commit install) and how to run manually (e.g., pre-commit run -a).

Additional context

We could also consider extending pre-commit with flake8 and Python formatter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions