diff --git a/.githooks/pre-commit b/.githooks/pre-commit index c5d7fb1..9be2050 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -12,4 +12,6 @@ if [[ ${result} -ne 0 ]] ; then exit 1 fi +cargo fmt --all + exit 0 \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0a002e0..e8b6e50 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,4 +36,12 @@ When writing code we ask you to code in a way that is consistent with the rest o We make use of `rustfmt` to format our code. You can install it by running `rustup component add rustfmt` and then running `cargo fmt --all` to format your code. It is generally recommended to run this command before you commit your code. If you use VSCode, you can install the [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=matklad.rust-analyzer) extension and enable the `Format on Save` option. -Also, **please do not write code that may panic**. If you are not sure how to handle a case, please use `Result` or `Option` to handle it. \ No newline at end of file +#### Git Hooks + +We make use of the pre-commit git hook to run `rustfmt` and `clippy` before you commit your code. To set up the git hooks you can run the following command: + + ```bash + git config core.hooksPath .githooks + ``` + +If you want to skip this check, you can use the `--no-verify` flag in your git commit command. Do note however that code that does not pass these checks will not be merged. \ No newline at end of file diff --git a/src/bot/commands/music/playing.rs b/src/bot/commands/music/playing.rs index 27d6d26..16c26bc 100644 --- a/src/bot/commands/music/playing.rs +++ b/src/bot/commands/music/playing.rs @@ -198,7 +198,7 @@ pub fn component(ctx: Context, mut interaction: MessageComponentInteraction) -> // Check if session still exists let mut session = match session_manager - .get_session(interaction.guild_id.expect("to contain a value")) + .get_session(interaction.guild_id.expect("to contain a value")) .await { Some(session) => session,