Skip to content

Comments

chore: add automatic clang-format with pre-commit hooks#572

Merged
jorgesg82 merged 5 commits intodevelopmentfrom
chore/formatter-automation
Feb 14, 2026
Merged

chore: add automatic clang-format with pre-commit hooks#572
jorgesg82 merged 5 commits intodevelopmentfrom
chore/formatter-automation

Conversation

@jorgesg82
Copy link
Contributor

@jorgesg82 jorgesg82 commented Feb 11, 2026

Summary

  • add shared .clang-format style for C/C++
  • add .pre-commit-config.yaml with clang-format hook on commit/push
  • add helper script tools/install-git-hooks.sh
  • add CI workflow .github/workflows/format-checks.yml
  • document local setup in README

Notes

  • this PR only adds formatter infrastructure, no functional code changes

Copilot AI review requested due to automatic review settings February 11, 2026 22:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces repository-wide C/C++ formatting infrastructure using clang-format integrated via pre-commit, with supporting CI checks and developer setup documentation.

Changes:

  • Add .clang-format style configuration and a pre-commit hook to run clang-format.
  • Add a helper script to install git hooks for pre-commit / pre-push.
  • Add a GitHub Actions workflow to run formatting checks in CI, and document local setup in the README.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tools/install-git-hooks.sh Adds a helper script to install pre-commit hooks locally.
README.md Documents local formatter setup and manual formatting execution.
.pre-commit-config.yaml Defines the clang-format hook and its scope.
.github/workflows/format-checks.yml Adds CI job to run pre-commit formatting checks.
.clang-format Adds shared clang-format style rules for the repo.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

echo "Instala con: pip install pre-commit"
exit 1
fi

Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This installer only checks for pre-commit, but the configured hook uses language: system and calls clang-format, so the hooks will fail if clang-format isn’t installed locally. Consider also checking command -v clang-format and providing install guidance (and/or switch to a pinned pre-commit clang-format repo to avoid system dependencies).

Suggested change
if ! command -v clang-format >/dev/null 2>&1; then
echo "clang-format no esta instalado."
echo "Instala clang-format con tu gestor de paquetes (por ejemplo: 'apt install clang-format' o 'brew install clang-format')."
exit 1
fi

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +33

Install hooks once:
```sh
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README setup instructions don’t mention installing clang-format, but the pre-commit hook currently relies on a system clang-format binary (language: system). Add the required clang-format install step (or change the hook to a pinned pre-commit clang-format repo so developers don’t need to install it manually).

Suggested change
Install hooks once:
```sh
Make sure `clang-format` is installed and available on your `PATH`, as the pre-commit hook invokes the system `clang-format` binary.
Install dependencies and hooks once:
```sh
# Install clang-format (examples; use the one appropriate for your OS)
# Debian/Ubuntu: sudo apt-get install clang-format
# Fedora: sudo dnf install clang-tools-extra
# macOS (Homebrew): brew install clang-format

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +35
- name: Install tools
run: |
python -m pip install --upgrade pip
python -m pip install pre-commit
sudo apt-get update
sudo apt-get install -y clang-format

Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI installs whatever clang-format version is provided by Ubuntu apt at the time, while local dev machines may have different versions (and the hook uses language: system). To avoid inconsistent formatting results, consider pinning clang-format via a pre-commit repo (mirrors-clang-format) or explicitly installing a specific clang-format-<version> package here and documenting the required version locally.

Copilot uses AI. Check for mistakes.
@jorgesg82 jorgesg82 force-pushed the chore/formatter-automation branch from c451752 to 66ea811 Compare February 14, 2026 00:08
@jorgesg82 jorgesg82 merged commit 240a66b into development Feb 14, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant