Skip to content

Commit

Permalink
Add a simple pre-commit git hook to verify each package's formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jessebraham committed Jan 16, 2023
1 parent 4d036c3 commit a542735
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

**H**ardware **A**bstraction **L**ayer crates for the **ESP32**, **ESP32-C2**, **ESP32-C3**, **ESP32-S2**, and **ESP32-S3** from Espressif.

These HALs are `no_std`; if you are looking for `std` support please use [esp-idf-hal] instead.
These HALs are `no_std`; if you are looking for `std` support, please use [esp-idf-hal] instead.

This project is still in the early stages of development, and as such there should be no expectation of API stability. A significant number of peripherals currently have drivers implemented (you can see a full list [here]) but have varying levels of functionality. For most basic tasks, this should be usable already.

If you have any questions, comments, or concerns please [open an issue], [start a new discussion], or join us on [Matrix]. For additional information regarding any of the crates in this repository please refer to the crate's README.
If you have any questions, comments, or concerns, please [open an issue], [start a new discussion], or join us on [Matrix]. For additional information regarding any of the crates in this repository, please refer to the crate's README.

| Crate | Target | Technical Reference Manual |
| :-----------: | :-----------------------------------------------------------------: | :------------------------: |
Expand Down Expand Up @@ -48,7 +48,7 @@ $ cargo install cargo-generate
$ cargo generate --git https://github.com/esp-rs/esp-template
```

For more information on using this template please refer to [its README].
For more information on using this template, please refer to [its README].

[cargo-generate]: https://github.com/cargo-generate/cargo-generate
[esp-template]: https://github.com/esp-rs/esp-template
Expand Down Expand Up @@ -86,6 +86,16 @@ RISC-V is officially supported by the official Rust compiler.
[esp-rs/rust]: https://github.com/esp-rs/rust
[esp-rs/rust-build]: https://github.com/esp-rs/rust-build

## Git Hooks

We provide a simple `pre-commit` hook to verify the formatting of each package prior to committing changes. This can be enabled by placing it in the `.git/hooks/` directory:

```bash
$ cp pre-commit .git/hooks/pre-commit
```

When using this hook, you can choose to ignore its failure on a per-commit basis by committing with the `--no-verify` flag; however, you will need to be sure that all packages are formatted when submitting a pull request.

## License

Licensed under either of:
Expand Down
14 changes: 14 additions & 0 deletions pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# Exit immediately on first non-zero status from a command in the script.
set -o errexit

# Ensure all tools being used are available.
command -v "cargo" >/dev/null 2>&1 || { echo >&2 "The 'cargo' command is not installed, exiting"; exit 1; }
command -v "rustfmt" >/dev/null 2>&1 || { echo >&2 "The 'rustfmt' command is not installed, exiting"; exit 1; }

# Check the formatting of all Rust code for every package.
for package in "esp"*/; do
# Check package is correctly formatted.
cargo fmt --all --manifest-path "${package}Cargo.toml" -- --check
done

0 comments on commit a542735

Please sign in to comment.