rumba icon indicating copy to clipboard operation
rumba copied to clipboard

Add pre-commit hook to format Rust

Open caugner opened this issue 2 years ago • 0 comments

Background: We use Rustfmt to enforce consistently formatted Rust code. The tool is run as part of the build-and-test workflow and will prevent merging a PR with Rust code that isn’t formatted.

Problem: When we commit changes to Rumba, the changes aren’t automatically formatted, so engineers have to run cargo fmt --all manually to ensure their code is properly formatted. If we push code that isn't formatted, then the GitHub workflow will fail on the GitHub PR. This means the author has to check out the code again, format it, commit and push again. In the lifetime of a PR, this can happen multiple times, causing unnecessary overhead and reducing developer efficiency.

Solution: Configure a Git Hook (like we already use in Yari) to automatically format all committed code in the pre-commit hook.

(Moved from https://mozilla-hub.atlassian.net/browse/MP-362.)

caugner avatar Oct 17 '23 10:10 caugner