-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use conda for pre-commit/clang-format versioning (#1435)
- use conda for pre-commit/clang-format versioning - update devel/git-hooks.md documentation accordingly
- Loading branch information
1 parent
6b88234
commit 41c74f5
Showing
3 changed files
with
43 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,51 @@ | ||
# Developer documentation: how to install (software for) git hooks | ||
|
||
You first need to have Python and pip | ||
We use [pre-commit](https://pre-commit.com) to check coding conventions, including | ||
white-space formatting rules. | ||
|
||
## Install [pre-commit](https://pre-commit.com) | ||
See https://pre-commit.com/#install but the following might work. | ||
Unfortunately, exact formatting used depends on the `clang-format` version. Therefore, | ||
you do have to install the same version as what is currently used in our GitHub Action. | ||
|
||
pip install pre-commit | ||
## Installation of software | ||
|
||
If this fails with a permission error, try adding `--user` to the command. | ||
We highly recommend to use `conda`: | ||
```sh | ||
cd /whereever/STIR | ||
conda env create --file pre-commit-environment.yml | ||
conda activate pre-commit-env | ||
``` | ||
|
||
If that fails with a message about `PyYAML` and `distutils`, try | ||
Alternative: | ||
|
||
pip install --ignore-installed PyYAML | ||
1. Install Python and pip | ||
|
||
## Install clang-format | ||
### debian/Ubuntu | ||
sudo apt install clang-format | ||
### MacOS | ||
brew install clang-format | ||
### Others | ||
search the internet and tell us | ||
2. Install [pre-commit](https://pre-commit.com). See https://pre-commit.com/#install but the following might work. | ||
```sh | ||
pip install pre-commit | ||
``` | ||
If this fails with a permission error, try adding `--user` to the command. If that fails with a message about `PyYAML` and `distutils`, try | ||
```sh | ||
pip install --ignore-installed PyYAML | ||
``` | ||
|
||
3. Install clang-format (but use correct version). At the time of writing, on Ubuntu 22.04, you can do | ||
```sh | ||
sudo apt install clang-format | ||
``` | ||
|
||
## Enable pre-commit hooks | ||
|
||
```sh | ||
cd /whereever/STIR | ||
pre-commit install | ||
``` | ||
|
||
If you need to work with a branch that was forked prior to in inclusion of clang-format, you will need to temporarily disable/uninstall pre-commit again: | ||
If you need to work with a branch that was forked prior to our use of `clang-format`, you will need to temporarily disable/uninstall pre-commit again: | ||
|
||
pre-commit uninstall | ||
|
||
or once-off with | ||
or one-off with | ||
|
||
git commit --no-verify | ||
|
||
You will then need to run `pre-commit run --all-files` when done before we will merge your pull request. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name: pre-commit-env | ||
channels: | ||
- conda-forge | ||
- defaults | ||
dependencies: | ||
- pre-commit | ||
- clang-format=14.0 |