diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..7969d49e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +repos: +- repo: local + hooks: + - id: fmt + name: fmt + description: Format files with cargo fmt. + entry: cargo fmt + language: system + types: [rust] + args: ["--all", "--", "--check"] + - id: clippy + name: clippy + description: Lint rust sources + entry: cargo clippy + language: system + args: ["--", "-W", "warnings"] + types: [rust] + pass_filenames: false \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 28b1d34c..57539d3b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -117,45 +117,51 @@ Where `TYPE` can be one of the following: For the initial start, fork the project and use git clone command to download the repository to your computer. A standard procedure for working on an issue would be to: 1. Clone the `surrealdb` repository and download to your computer. -```bash -git clone https://github.com/surrealdb/surrealdb -``` + ```bash + git clone https://github.com/surrealdb/surrealdb + ``` -1. Pull all changes from the upstream `main` branch, before creating a new branch - to ensure that your `main` branch is up-to-date with the latest changes: -```bash -git pull -``` + (Optional): Install [pre-commit](https://pre-commit.com/#install) to run the checks before each commit and run: -2. Create new branch from `main` like: `bugfix-548-ensure-queries-execute-sequentially`: -```bash -git checkout -b "[the name of your branch]" -``` + ```bash + pre-commit install + ``` -3. Make changes to the code, and ensure all code changes are formatted correctly: -```bash -cargo fmt -``` +2. Pull all changes from the upstream `main` branch, before creating a new branch - to ensure that your `main` branch is up-to-date with the latest changes: + ```bash + git pull + ``` -4. Commit your changes when finished: -```bash -git add -A -git commit -m "[your commit message]" -``` +3. Create new branch from `main` like: `bugfix-548-ensure-queries-execute-sequentially`: + ```bash + git checkout -b "[the name of your branch]" + ``` -5. Push changes to GitHub: -```bash -git push origin "[the name of your branch]" -``` +4. Make changes to the code, and ensure all code changes are formatted correctly: + ```bash + cargo fmt + ``` -6. Submit your changes for review, by going to your repository on GitHub and clicking the `Compare & pull request` button. +5. Commit your changes when finished: + ```bash + git add -A + git commit -m "[your commit message]" + ``` -7. Ensure that you have entered a commit message which details about the changes, and what the pull request is for. +6. Push changes to GitHub: + ```bash + git push origin "[the name of your branch]" + ``` -8. Now submit the pull request by clicking the `Create pull request` button. +7. Submit your changes for review, by going to your repository on GitHub and clicking the `Compare & pull request` button. -9. Wait for code review and approval. +8. Ensure that you have entered a commit message which details about the changes, and what the pull request is for. -10. After approval, merge your pull request. +9. Now submit the pull request by clicking the `Create pull request` button. + +10. Wait for code review and approval. + +11. After approval, merge your pull request. ## Other Ways to Help diff --git a/flake.nix b/flake.nix index 03cf23dc..4a6eadf8 100644 --- a/flake.nix +++ b/flake.nix @@ -115,7 +115,7 @@ hardeningDisable = [ "fortify" ]; depsBuildBuild = buildSpec.depsBuildBuild or [ ] - ++ [ rustToolchain ] ++ (with pkgs; [ nixfmt cargo-watch wasm-pack ]); + ++ [ rustToolchain ] ++ (with pkgs; [ nixfmt cargo-watch wasm-pack pre-commit]); inherit (util) SURREAL_BUILD_METADATA; })) util.platforms);