aboutsummaryrefslogtreecommitdiff
path: root/CONTRIBUTING.md
diff options
context:
space:
mode:
authorQuentin <quentin@dufour.io>2021-09-20 16:06:02 +0200
committerQuentin <quentin@dufour.io>2021-09-20 16:06:02 +0200
commit4d4d453afa3edafe71db2ae60171b8696b38a3c9 (patch)
tree64a54012efbac76bca6c5f0d8214fdae44743bc8 /CONTRIBUTING.md
parent2bbc9109991f8bb79a09a965a1d2779e1749b25b (diff)
parent68cb4d5482649baca3a79d3fd0e3449a6af0533b (diff)
downloaddiplonat-4d4d453afa3edafe71db2ae60171b8696b38a3c9.tar.gz
diplonat-4d4d453afa3edafe71db2ae60171b8696b38a3c9.zip
Merge pull request 'Extensively use rustfmt' (#11) from quality/rustfmt into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/diplonat/pulls/11
Diffstat (limited to 'CONTRIBUTING.md')
-rw-r--r--CONTRIBUTING.md23
1 files changed, 17 insertions, 6 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f8de6cc..01e1e12 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -8,12 +8,13 @@
#### Installing rustfmt
-You can run `rustfmt` with Rust 1.24 and above.
+You must install a very recent version of `rustfmt` through rust nightly
To install:
```
-rustup component add rustfmt
+rustup toolchain install nightly-x86_64-unknown-linux-gnu
+rustup component add rustfmt --toolchain nightly
```
#### Usage
@@ -21,14 +22,24 @@ rustup component add rustfmt
To run on Diplonat, launch the following in the root directory:
```
-cargo fmt --all
+cargo +nightly fmt
```
-This will format the whole repository using the settigs defined in [`.rustfmt.toml`](./.rustfmt.toml): soft tabs of 2 spaces.
+This will format the whole repository using the settigs defined in [`.rustfmt.toml`](./.rustfmt.toml).
#### Auto-format code
You can automate formatting in a number of ways:
-* [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.
+[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
+```