generated from allenai/python-package-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds [Lefthook](https://github.com/evilmartians/lefthook/) as a way to manage Git Hooks and automatically run ruff, PyRight and a commit message validator on commit. For now, `ruff` and `pyright` validators are turned off since there are many errors. They will be turned on once we have fixed the errors.
- Loading branch information
1 parent
fd533ab
commit 5aa200d
Showing
6 changed files
with
62 additions
and
0 deletions.
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,19 @@ | ||
#!/bin/bash | ||
|
||
# This script takes in some text from STDIN (presumably a commit message) | ||
# and validates whether it adheres to our commit message format. | ||
# | ||
# We are using Conventional Commits as a commit message format. | ||
# See: https://www.conventionalcommits.org/en/v1.0.0/ | ||
|
||
INPUT_FILE=$1 | ||
|
||
PATTERN="^((chore|ci|docs|feat|fix|perf|refactor|revert|test)(\(\w+\))?(!)?(: (.*\s*)*))" | ||
grep -E "$PATTERN" $INPUT_FILE | ||
MATCH=$? | ||
|
||
if [ $MATCH -ne 0 ]; then | ||
echo "Bad commit message. Must be in Conventional Commits style.\n\nSee: https://www.conventionalcommits.org/en/v1.0.0/" | ||
exit 1 | ||
fi | ||
|
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
ruff | ||
pytest | ||
pyright | ||
setuptools |
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 |
---|---|---|
@@ -1,11 +1,19 @@ | ||
# This file was autogenerated by uv via the following command: | ||
# uv pip compile dev-requirements.in -o dev-requirements.txt | ||
exceptiongroup==1.2.1 | ||
# via pytest | ||
iniconfig==2.0.0 | ||
# via pytest | ||
nodeenv==1.8.0 | ||
# via pyright | ||
packaging==24.0 | ||
# via pytest | ||
pluggy==1.5.0 | ||
# via pytest | ||
pyright==1.1.360 | ||
pytest==8.1.1 | ||
ruff==0.4.2 | ||
setuptools==69.5.1 | ||
# via nodeenv | ||
tomli==2.0.1 | ||
# via pytest |
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,10 @@ | ||
pre-commit: | ||
commands: | ||
# ruff: | ||
# run: .venv/bin/ruff check --fix | ||
# pyright: | ||
# run: .venv/bin/pyright | ||
|
||
commit-msg: | ||
template-checker: | ||
runner: bash |
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