-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #76356 - caass:hooks, r=jyn514
Add a command to install a git hook to automatically run `x.py test tidy --bless` Some folks (such as myself) would probably find a lot of convenience in a pre-commit hook that automatically runs tidy before committing, to avoid burning CI time learning that your commit wasn't tidy. I'm absolutely positive I have missed some stuff. I basically just got this to where you can run `./x.py run install-git-hook` and then clicked the commit button. Please let me know what else you'd like me to add before this can be merged! [rustc-dev-guide companion PR](rust-lang/rustc-dev-guide#848)
- Loading branch information
Showing
3 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Call `tidy --bless` before each commit | ||
# Copy this scripts to .git/hooks to activate, | ||
# and remove it from .git/hooks to deactivate. | ||
# | ||
|
||
set -Eeuo pipefail | ||
|
||
ROOT_DIR="$(git rev-parse --show-toplevel)"; | ||
COMMAND="$ROOT_DIR/x.py test tidy --bless"; | ||
|
||
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then | ||
COMMAND="python $COMMAND" | ||
fi | ||
|
||
echo "Running pre-commit script '$COMMAND'"; | ||
|
||
cd "$ROOT_DIR" | ||
|
||
$COMMAND; |