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

CI: Call local python pre-commit scripts via shell #92556

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,17 @@ repos:
- id: make-rst
name: make-rst
language: python
entry: python3 doc/tools/make_rst.py doc/classes modules platform --dry-run --color
entry: misc/scripts/python.sh doc/tools/make_rst.py
args: [doc/classes, modules, platform, --dry-run, --color]
pass_filenames: false
files: ^(doc/classes|.*/doc_classes)/.*\.xml$

- id: doc-status
name: doc-status
language: python
entry: python3 doc/tools/doc_status.py
entry: misc/scripts/python.sh doc/tools/doc_status.py
args: [doc/classes, modules/*/doc_classes, platform/*/doc_classes]
pass_filenames: false
files: ^(doc/classes|.*/doc_classes)/.*\.xml$

- id: eslint
Expand Down Expand Up @@ -126,7 +129,7 @@ repos:
- id: copyright-headers
name: copyright-headers
language: python
entry: python3 misc/scripts/copyright_headers.py
entry: misc/scripts/python.sh misc/scripts/copyright_headers.py
files: \.(c|h|cpp|hpp|cc|cxx|m|mm|inc|java)$
exclude: |
(?x)^(
Expand All @@ -141,7 +144,7 @@ repos:
- id: header-guards
name: header-guards
language: python
entry: python3 misc/scripts/header_guards.py
entry: misc/scripts/python.sh misc/scripts/header_guards.py
files: \.(h|hpp)$
exclude: |
(?x)^(
Expand All @@ -153,7 +156,7 @@ repos:
- id: file-format
name: file-format
language: python
entry: python3 misc/scripts/file_format.py
entry: misc/scripts/python.sh misc/scripts/file_format.py
types_or: [text]
exclude: |
(?x)^(
Expand All @@ -170,7 +173,7 @@ repos:
- id: dotnet-format
name: dotnet-format
language: python
entry: python3 misc/scripts/dotnet_format.py
entry: misc/scripts/python.sh misc/scripts/dotnet_format.py
types_or: [c#]

# End of upstream Godot pre-commit hooks.
Expand Down
19 changes: 19 additions & 0 deletions misc/scripts/python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

if [ $# -eq 0 ]; then
echo "No arguments provided."
exit 1
fi

PYTHON_ALIASES=("python3" "python" "py")

for alias in "${PYTHON_ALIASES[@]}"
do
if command "$alias" --version > /dev/null 2>&1; then
exec "$alias" "$@"
exit $?
fi
done

echo "Python not found." 1>&2
exit 1
Loading