Open concur1 opened 1 month ago
Hi @benfdking and @gvozdvmozgu I have created a pre-commit hook here: https://github.com/concur1/sqruff-pre-commit
I mainly tried to just copy the ruff pre-commit hook, but based it on cargo/rust instead of python/pypi as I thought that is more appropriate here.
I was wondering if you would want to take ownership of this or if you would prefer to leave it with me?
It works (from my testing at least) but there is one small thing that someone who knows more about rust might be able to help with: I have been forced to include a dummy/useless src/main.rs
file even though it does not get used. As far as I can tell cargo requires some src files to exist. Does anyone know if there is a cargo.toml
config that can be used to allow building with no source files?
Why do we need to create a package?
I presume we can just take the commit yaml
file and merge that into this repo?
Why do we need to create a package?
When people run pre-commit it will point to this repo and install sqruff for them based on the cargo.toml
. I will give reasons why I think it needs to be a separate repo (for now) bellow.
I presume we can just take the commit yaml file and merge that into this repo?
I don't think that is possible with the current sqruff structure, we would need the root cargo.toml to create a sqruff binary, and ideally that would be all that it does. I will explain more below.
I couldn't find any simimlar rust examples. From reading the pre-commit documentation and asking in their discord it seems that:
.pre-commit-hook.yaml
and the cargo.toml
must live in the repo root.sqruff
binary is under crates/cli
so it will not get picked up by pre-commit.cargo.toml
(not found in the docs and I have asked in discord).
Pre commit hooks can be a useful development workflow that allow formatters/linters to run before a change is commited to git. There is a python pre-commit-hook utility that allows these to be configured with yaml. Here is an example of Ruff's pre-commit-hook: https://github.com/astral-sh/ruff-pre-commit