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

Make the pre-push script work on directories with spaces #105853

Merged
merged 1 commit into from
Dec 23, 2022
Merged
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
12 changes: 2 additions & 10 deletions src/etc/pre-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,8 @@ set -Eeuo pipefail
# https://github.com/rust-lang/rust/issues/77620#issuecomment-705144570
unset GIT_DIR
ROOT_DIR="$(git rev-parse --show-toplevel)"
COMMAND="$ROOT_DIR/x.py test tidy"

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'"
echo "Running pre-push script $ROOT_DIR/x test tidy"

cd "$ROOT_DIR"

$COMMAND
./x test tidy
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already in a .sh file, so we know there must be a shell available.

Copy link
Contributor

@caass caass Dec 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you just run a python script like this?

edit: TIL

Copy link
Member Author

@jyn514 jyn514 Dec 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it requires a shebang like you found, and not every platform has exactly python. see #94829 and #71818.