-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-merge-commit
More file actions
executable file
·38 lines (35 loc) · 1.18 KB
/
pre-merge-commit
File metadata and controls
executable file
·38 lines (35 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
me=$(basename "$0")
is_python3() {
"$@" -c 'import sys; sys.exit(0 if sys.version_info[0] == 3 else 1)' >/dev/null 2>&1
}
case "$OSTYPE" in
msys*|mingw*|cygwin*|win32*)
echo "Running ${me} on Windows"
if command -v py >/dev/null 2>&1 && is_python3 py -3; then
PYTHON_EXECUTABLE=(py -3)
else
python3_path=$(command -v python3 2>/dev/null || true)
if [ -n "$python3_path" ] && [[ "$python3_path" != *WindowsApps* ]] && is_python3 python3; then
PYTHON_EXECUTABLE=(python3)
elif command -v python >/dev/null 2>&1 && is_python3 python; then
PYTHON_EXECUTABLE=(python)
else
echo "Error: Python 3 not found. Please install Python 3 or disable the Microsoft Store python alias."
exit 1
fi
fi
;;
*)
echo "Running ${me} on linux / mac / unix"
if command -v python3 >/dev/null 2>&1 && is_python3 python3; then
PYTHON_EXECUTABLE=(python3)
elif command -v python >/dev/null 2>&1 && is_python3 python; then
PYTHON_EXECUTABLE=(python)
else
echo "Error: Python not found or not runnable"
exit 1
fi
;;
esac
"${PYTHON_EXECUTABLE[@]}" "${BASH_SOURCE[0]%.*}.py" "$@"