-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-merge-commit
More file actions
executable file
·35 lines (32 loc) · 1.08 KB
/
pre-merge-commit
File metadata and controls
executable file
·35 lines (32 loc) · 1.08 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
#!/usr/bin/env bash
me=$(basename "$0")
is_python3() {
"$1" -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 python3 > /dev/null 2>&1 && is_python3 python3; then
PYTHON_EXECUTABLE=(python3)
elif command -v py > /dev/null 2>&1 && py -3 -c 'import sys; sys.exit(0 if sys.version_info[0] == 3 else 1)' > /dev/null 2>&1; then
PYTHON_EXECUTABLE=(py -3)
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
;;
*)
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" "$@"