diff options
| author | Cheng XU <git@xuc.me> | 2022-04-05 23:13:46 -0700 |
|---|---|---|
| committer | Cheng XU <git@xuc.me> | 2022-04-11 12:02:40 -0700 |
| commit | 365d4f4fd0caa3e4e1dd95eb42f7244e1424d37e (patch) | |
| tree | da75c17e1883459a86e71aebeb10b1cf0d92c2af | |
| parent | 625e4dd13a3abd0cc59807af66c3c4cd63440852 (diff) | |
| download | rust-365d4f4fd0caa3e4e1dd95eb42f7244e1424d37e.tar.gz rust-365d4f4fd0caa3e4e1dd95eb42f7244e1424d37e.zip | |
pre-push.sh: Use python3 if python is not found
Since Python 2 has reached EOL, `python` may not be available in certain systems (e.g., recent macOS). We should use `python3` in this case to avoid error like `python: No such file or directory`.
| -rwxr-xr-x | src/etc/pre-push.sh | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/etc/pre-push.sh b/src/etc/pre-push.sh index a78725f2ab0..5f5b48bc1c0 100755 --- a/src/etc/pre-push.sh +++ b/src/etc/pre-push.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Call `tidy --bless` before each commit +# Call `tidy --bless` before git push # Copy this script to .git/hooks to activate, # and remove it from .git/hooks to deactivate. # @@ -14,6 +14,8 @@ COMMAND="$ROOT_DIR/x.py test tidy --bless" if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then COMMAND="python $COMMAND" +elif ! command -v python &> /dev/null; then + COMMAND="python3 $COMMAND" fi echo "Running pre-push script '$COMMAND'" |
