Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a system hook for people who don't have the rust toolchain #331

Merged

Conversation

IamTheFij
Copy link
Contributor

This PR will add back the option for a system pre-commit hook. Otherwise every update will require cargo and the rust tool chain, which some Lua developers may not have and may prefer to install their own binary.

One downside to system hooks is that the version tag is really irrelevant as it won't update the checker.

Another option would be to do something like this: https://github.com/shellcheck-py/shellcheck-py and provide a wrapper. This example uses Python to manage the download and installation. Since this person has put this in it's own repo, they are hard coding the version and sha's.

I'm tempted to write a Python package that can accept a git repo as an argument and then it will download the release using repo metadata (reading Cargo.toml) and then execute that binary. This would be helpful, not just for StyLua, but any statically compiled checkers that have dependencies.

@JohnnyMorganz
Copy link
Owner

Thanks!

@JohnnyMorganz JohnnyMorganz merged commit 20f4402 into JohnnyMorganz:master Jan 4, 2022
@gegoune
Copy link

gegoune commented Jan 4, 2022

So how could this system version be used?

@JohnnyMorganz
Copy link
Owner

So how could this system version be used?

I assume something like this: (disclaimer, i haven't actually tested this):

repos:
-   repo: https://github.com/johnnymorganz/stylua
    rev: v0.11.3
    hooks:
    -   id: stylua-system

Changing stylua-system with stylua would use the cargo toolchain instead

@gegoune
Copy link

gegoune commented Jan 5, 2022

Getting this:

$ pre-commit
[INFO] Initializing environment for https://github.com/johnnymorganz/stylua.
[ERROR] `stylua-system` is not present in repository https://github.com/johnnymorganz/stylua.  Typo? Perhaps it is introduced in a newer version?  Often `pre-commit autoupdate` fixes this.
$ pre-commit autoupdate
Updating https://github.com/johnnymorganz/stylua ... Cannot update because the update target is missing these hooks:
stylua-system
$

@gegoune
Copy link

gegoune commented Jan 7, 2022

It works for rev: master so I assume it wasn't part of release?

@IamTheFij
Copy link
Contributor Author

Yea, I think the release was cut before this was merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants