2021-09-11 14:34:03 +00:00
|
|
|
# Contributing to Diplonat
|
|
|
|
|
|
|
|
## Development guidelines
|
|
|
|
|
|
|
|
### Code formatting
|
|
|
|
|
|
|
|
[Our CI pipeline](./.drone.yml) features a verification of the code format, using [rustfmt](https://github.com/rust-lang/rustfmt).
|
|
|
|
|
|
|
|
#### Installing rustfmt
|
|
|
|
|
2021-09-20 13:18:49 +00:00
|
|
|
You must install a very recent version of `rustfmt` through rust nightly
|
2021-09-11 14:34:03 +00:00
|
|
|
|
|
|
|
To install:
|
|
|
|
|
|
|
|
```
|
2021-09-20 13:18:49 +00:00
|
|
|
rustup toolchain install nightly-x86_64-unknown-linux-gnu
|
|
|
|
rustup component add rustfmt --toolchain nightly
|
2021-09-11 14:34:03 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
#### Usage
|
|
|
|
|
|
|
|
To run on Diplonat, launch the following in the root directory:
|
|
|
|
|
|
|
|
```
|
2021-09-20 13:18:49 +00:00
|
|
|
cargo +nightly fmt
|
2021-09-11 14:34:03 +00:00
|
|
|
```
|
|
|
|
|
2021-09-20 13:18:49 +00:00
|
|
|
This will format the whole repository using the settigs defined in [`.rustfmt.toml`](./.rustfmt.toml).
|
2021-09-11 14:34:03 +00:00
|
|
|
|
|
|
|
#### Auto-format code
|
|
|
|
|
|
|
|
You can automate formatting in a number of ways:
|
|
|
|
|
2021-09-20 13:18:49 +00:00
|
|
|
[Setup your IDE to use `rustfmt`](https://github.com/rust-lang/rustfmt#running-rustfmt-from-your-editor).
|
|
|
|
|
|
|
|
Setup a git hook to run `rustfmt` before each commit:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
cat <<EOF > .git/hooks/pre-commit
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
cargo +nightly fmt
|
|
|
|
EOF
|
|
|
|
chmod +x .git/hooks/pre-commit
|
|
|
|
```
|