pytorch/tools/git-pre-commit
Pieter Noordhuis 6ff0c6ca3f Remove THD (#22065)
Summary:
It's been ~9 months since moving THD to the `torch.distributed.deprecated` namespace (see https://github.com/pytorch/pytorch/issues/11405) and we haven't seen issues related to it, so it's time to remove it.

Closes https://github.com/pytorch/pytorch/issues/18967.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/22065

Reviewed By: mrshenli

Differential Revision: D15983669

Pulled By: pietern

fbshipit-source-id: 2a2f5866f9a63040bc7cef3956d5fd215aba7165
2019-06-25 12:19:13 -07:00

43 lines
997 B
Bash
Executable File

#!/bin/bash
set -e
echo "Running pre-commit flake8"
python tools/flake8_hook.py
if [ $(which clang-tidy) ]
then
echo "Running pre-commit clang-tidy"
python tools/clang_tidy.py \
--paths torch/csrc \
--diff HEAD \
-g"-torch/csrc/jit/export.cpp" \
-g"-torch/csrc/jit/import.cpp" \
-j
else
echo "WARNING: Couldn't find clang-tidy executable."
echo " Please install it if you want local clang-tidy checks."
fi
echo "Running pre-commit clang-format"
CLANG_FORMAT_DIFF=$(python tools/clang_format.py)
if [[ ${CLANG_FORMAT_DIFF} ]]
then
echo "${CLANG_FORMAT_DIFF}"
# Prompt user to accept clang-format changes
# From: https://stackoverflow.com/a/10015707
exec < /dev/tty
while true; do
read -p "[clang-format hook] Accept changes? (Y/n) " yn
if [ "$yn" = "" ]; then
yn='Y'
fi
case $yn in
[Yy] ) python tools/clang_format.py --accept-changes; break;;
[Nn] ) exit 1;;
* ) echo "Please answer y or n.";;
esac
done
fi