Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ impl<'a> Builder<'a> {
install::Src,
install::Rustc
),
Kind::Run => describe!(run::ExpandYamlAnchors, run::BuildManifest,),
Kind::Run => describe!(run::ExpandYamlAnchors, run::BuildManifest),
}
}

Expand Down
22 changes: 22 additions & 0 deletions src/etc/pre-commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/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.
#
# For help running bash scripts on Windows,
# see https://stackoverflow.com/a/6413405/6894799
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, maybe a good follow-up would be to have a version of this for powershell too. No need to add it now though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From what I can tell, git only understands unix-like scripts, and won't run e.g. pre-commit.ps1. I suspect that if the user has git installed, they'll be able to run git scripts as well, so actually this line is redundant...I think...I haven't used git on windows in a while.

Copy link
Member

Choose a reason for hiding this comment

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

cc @mati865 - do you know if this will work on windows, and if not, how to make it work?

Copy link
Member

Choose a reason for hiding this comment

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

@jyn514 Git for Windows ships bash shell.
I haven't tried using hooks there but they should work.

I hate powershell so personally I use bash/zsh everywhere, even on Windows.

#

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";

$COMMAND;