Update precommit hooks to work in GitHub Desktop (Port) (#8773)

* Update precommit hooks to work in GitHub Desktop

* Add helpful comment

* dmi.merge too just in case this helps somehow, not tested though

* Update tools/hooks/python.sh

Co-authored-by: Ling <lingbleed@gmail.com>

Co-authored-by: Tad Hardesty <tad@platymuus.com>
Co-authored-by: Ling <lingbleed@gmail.com>
This commit is contained in:
TheGamerdk
2020-06-08 03:14:37 +02:00
committed by GitHub
parent fe3b7efab6
commit 4ea613ed1b
3 changed files with 12 additions and 6 deletions

View File

@@ -1,2 +1,2 @@
#!/bin/bash
#!/bin/sh
exec tools/hooks/python.sh -m merge_driver_dmi "$@"

View File

@@ -1,2 +1,3 @@
#!/bin/bash
#!/bin/sh
# `sh` must be used here instead of `bash` to support GitHub Desktop.
exec tools/hooks/python.sh -m precommit

View File

@@ -1,17 +1,22 @@
#!/bin/bash
#!/bin/sh
# `sh` must be used here instead of `bash` to support GitHub Desktop.
set -e
if command -v python3 >/dev/null 2>&1; then
PY=python3
else
elif command -v python >/dev/null 2>&1; then
PY=python
elif command -v py >/dev/null 2>&1; then
PY=py
else
echo "Please install Python 3.6 or later."
fi
PATHSEP=$($PY - <<'EOF'
import sys, os
if sys.version_info.major != 3 or sys.version_info.minor < 6:
sys.stderr.write("Python 3.6+ is required: " + sys.version + "\n")
sys.stderr.write("Python 3.6 or later is required, but you have: " + sys.version + "\n")
exit(1)
print(os.pathsep)
EOF
)
export PYTHONPATH=tools/mapmerge2/${PATHSEP}${PYTHONPATH}
$PY "$@"
exec $PY "$@"