-
-
Notifications
You must be signed in to change notification settings - Fork 82
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 pre-commit hook #565
Open
amitds1997
wants to merge
1
commit into
Kampfkarren:main
Choose a base branch
from
amitds1997:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add pre-commit hook #565
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- id: selene-system | ||
name: selene (system) | ||
description: An opinionated Lua code linter | ||
entry: selene | ||
language: system | ||
types: [lua] | ||
|
||
- id: selene-docker | ||
name: selene (docker) | ||
description: An opinionated Lua code linter | ||
entry: /selene | ||
language: docker | ||
types: [lua] | ||
|
||
- id: selene-github | ||
name: selene (GitHub) | ||
description: An opinionated Lua code linter | ||
entry: selene | ||
language: python | ||
types: [lua] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Pre-commit | ||
|
||
`pre-commit` allows integration of `selene` into your Git workflow using git hooks. After [installing pre-commit](https://pre-commit.com/#install), add one of the following configurations to your `.pre-commit-config.yaml` file: | ||
|
||
* Use the `selene` binary present on the system path (Should be pre-installed): | ||
|
||
```yaml | ||
repos: | ||
- repo: https://github.com/Kampfkarren/selene | ||
rev: '' | ||
hooks: | ||
- id: selene-system | ||
``` | ||
|
||
* Use `selene` through GitHub releases: | ||
|
||
```yaml | ||
repos: | ||
- repo: https://github.com/Kampfkarren/selene | ||
rev: '' | ||
hooks: | ||
- id: selene-github | ||
``` | ||
|
||
* Use the `selene` binary present in the `selene` docker image (Since this uses docker, it might take some time to bootstrap and is slower than the other two options): | ||
|
||
```yaml | ||
repos: | ||
- repo: https://github.com/Kampfkarren/selene | ||
rev: '' | ||
hooks: | ||
- id: selene-docker | ||
``` | ||
|
||
You may see a `warning` being generated when pre-commit runs. To resolve that, set the `rev` key to any selene tag or commit, for e.g. `rev: '0.26.2'`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[build-system] | ||
requires = ["release-gitter[builder]"] | ||
build-backend = "pseudo_builder" | ||
|
||
[tool.release-gitter] | ||
git-url = "https://github.com/Kampfkarren/selene" | ||
extract-files = ["selene"] | ||
format = "selene-{version}-{system}.zip" | ||
exec = "chmod +x selene" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rust-based pre-commit does not work because pre-commit hardcodes the
--path
to.
(source) which leads to build failure with error:found a virtual manifest at <path>/Cargo.toml instead of a package manifest
.Pre-commit maintainer disagrees with making
--path
configurable so it is not possible to add a rust based hook: pre-commit/pre-commit#2931 unless we somehow make it possible to install the binary from root level.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's possible to point
entry
to a custom install script. But we'd need to handle the caching, unless we distribute the executable directly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was unsure if we wanted a custom install script just for the pre-commit use case. I can add it if that's something we are okay with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would depend on how it would look like. Caching binaries by version may not be trivial and we don't get the same advantages
language: rust
gets, which makes me think it's likely not worth the effort to support this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. That's why went ahead with only setting up
system
anddocker
workflows. Is there some trivial way to make this work by may be a configuration change at our end? I did some preliminary research but did not find much (but then I have not worked withrust
ever before).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you looked at how StyLua handles the pre-commit hook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Their
rust
workflow works because they do not use workspaces.The
python
workflow seems interesting. We can integrate it, but it would depend on a python package (https://pypi.org/project/release-gitter/) to do the release download for us. If that is something we are okay with, I can add it 👍There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added GitHub release based pre-commit hook in 5f1a755