grin/doc/style.md
AntiochP 510d7fc331 git pre-commit hook to run rustfmt on modified files (#110)
* git pre-commit hook to run rustfmt on modified files
* add docs for rustfmt
* add CONTRIBUTING file
2017-09-01 00:54:15 +00:00

898 B

Grin Style Guide

Grin uses rustfmt to maintain consist formatting.

Install rustfmt (nightly)

Note: we assume Rust has been installed via Rustup. See build docs for more info.

rustfmt itself requires the nightly toolchain -

rustup update
rustup install nightly
rustup run nightly cargo install rustfmt-nightly

Install git pre-commit hook

There is a basic git pre-commit hook in the repo.

The pre-commit hook will not prevent commits if style issues are present but it will indicate any files that need formatting.

To enable this create a symlink in .git/hooks (note the relative path) -

cd .git/hooks
ln -s -f ../../.hooks/pre-commit

Running rustfmt

To run rustfmt against a single file in grin -

cargo +nightly fmt -- ./core/src/lib.rs