Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated script for setting up the formatting. #193

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion scripts/setup-formatting.bash
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ source $script_own_dir/../setup.bash
# Setting up formatting
cp -n ${PACKAGE_TEMPLATES}/.clang-format .
cp -n ${PACKAGE_TEMPLATES}/.pre-commit-config.yaml .
touch ".codespell-ignore-words.txt"
cp -n ${PACKAGE_TEMPLATES}/.codespell-ignore-words.txt .
pre-commit install
pre-commit autoupdate

Expand Down
1 change: 1 addition & 0 deletions templates/package/.codespell-ignore-words.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
manuel
30 changes: 16 additions & 14 deletions templates/package/_append_to_README_code_formatting.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@

## Code Formatting

This repository uses `pre-commit` tool for code formatting.
The tool checks formatting each time you commit to a repository.
To install it locally use:
```
pip3 install pre-commit # (prepend `sudo` if you want to install it system wide)
```
Formatters and linters are integrated to the repository as pre-commit-hooks and uses `pre-commit` tool to execute them. For list of hooks and their sources check `.pre-commit-config.yaml` file.

To install `pre-commit` tool locally use:
```
pip3 install pre-commit # (prepend `sudo` if you want to install it system wide)
```

Then set it up for automatic execution on every commit using:
```
pre-commit install
```

To run it initially over the whole repo you can use:
```
pre-commit run -a
```
```
pre-commit run -a
```

If you get error that something is missing on your computer, do the following for:
**NOTE**: make sure that you have sources your ROS workspace before running `pre-commit` because it uses some office ROS 2 `ament_*` formatters.

- `clang-format-10`
```
sudo apt install clang-format-10
```
Sometimes there might a need to avoid formatting of a certain commit. If so add `-n` flag to your `git commit` command to skip the `pre-commit` chekcs.
Loading