Skip to content

Commit

Permalink
Add lua pre-commit hooks (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
paddyroddy committed Sep 6, 2024
1 parent 739567e commit 8bec084
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
name: LaTeX hooks
require_serial: true
verbose: true
- description: Default pre-commit hooks for Lua repos
entry: ./precommit/lua/lua_hooks.py
id: lua-hooks
language: script
name: Lua hooks
require_serial: true
verbose: true
- description: Default pre-commit hooks for Python repos
entry: ./precommit/python/python_hooks.py
id: python-hooks
Expand Down
1 change: 1 addition & 0 deletions .renovaterc.json5
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
fileMatch: [
"precommit/general/general-hooks.yaml",
"precommit/latex/latex-hooks.yaml",
"precommit/lua/lua-hooks.yaml",
"precommit/python/python-hooks.yaml",
],
},
Expand Down
14 changes: 14 additions & 0 deletions precommit/lua/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Lua pre-commit config

In a repository that requires [pre-commit](https://pre-commit.com), simply add a
file called `.pre-commit-config.yaml` with the following code.

```yaml
repos:
- repo: https://github.com/paddyroddy/.github
rev: v0.1.0
hooks:
- id: lua-hooks
```
Then run `pre-commit install; pre-commit autoupdate`.
1 change: 1 addition & 0 deletions precommit/lua/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# noqa: D104
6 changes: 6 additions & 0 deletions precommit/lua/lua-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
repos:
- repo: https://github.com/JohnnyMorganz/StyLua
rev: v0.20.0
hooks:
- id: stylua-github
25 changes: 25 additions & 0 deletions precommit/lua/lua_hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python
"""Lua pre-commit hooks."""

import pathlib
import sys

HERE = pathlib.Path(__file__).resolve()

sys.path.append(str(HERE.parents[1]))

from _run_hooks import run_hooks # noqa: E402


def main() -> int:
"""
Run the Lua pre-commit hooks.
Returns
The return code of the process
"""
return run_hooks(pathlib.Path("lua/lua-hooks.yaml"))


if __name__ == "__main__":
sys.exit(main())

0 comments on commit 8bec084

Please sign in to comment.