Add precommit hooks (#2119)
This commit is contained in:
parent
5ebf4ee963
commit
93904eb24b
3 changed files with 54 additions and 30 deletions
18
.pre-commit-config.yaml
Normal file
18
.pre-commit-config.yaml
Normal file
|
@ -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
|
|
@ -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:
|
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.
|
1. Clone the `surrealdb` repository and download to your computer.
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/surrealdb/surrealdb
|
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:
|
(Optional): Install [pre-commit](https://pre-commit.com/#install) to run the checks before each commit and run:
|
||||||
```bash
|
|
||||||
git pull
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Create new branch from `main` like: `bugfix-548-ensure-queries-execute-sequentially`:
|
```bash
|
||||||
```bash
|
pre-commit install
|
||||||
git checkout -b "[the name of your branch]"
|
```
|
||||||
```
|
|
||||||
|
|
||||||
3. Make changes to the code, and ensure all code changes are formatted correctly:
|
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
|
```bash
|
||||||
cargo fmt
|
git pull
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Commit your changes when finished:
|
3. Create new branch from `main` like: `bugfix-548-ensure-queries-execute-sequentially`:
|
||||||
```bash
|
```bash
|
||||||
git add -A
|
git checkout -b "[the name of your branch]"
|
||||||
git commit -m "[your commit message]"
|
```
|
||||||
```
|
|
||||||
|
|
||||||
5. Push changes to GitHub:
|
4. Make changes to the code, and ensure all code changes are formatted correctly:
|
||||||
```bash
|
```bash
|
||||||
git push origin "[the name of your branch]"
|
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
|
## Other Ways to Help
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@
|
||||||
hardeningDisable = [ "fortify" ];
|
hardeningDisable = [ "fortify" ];
|
||||||
|
|
||||||
depsBuildBuild = buildSpec.depsBuildBuild or [ ]
|
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;
|
inherit (util) SURREAL_BUILD_METADATA;
|
||||||
})) util.platforms);
|
})) util.platforms);
|
||||||
|
|
Loading…
Reference in a new issue