add back pre-commit hook (#33366)

* add pre-commit

* space

* post

* e
old-commit-hash: b87414c749
pull/33386/head
Maxime Desroches 8 months ago committed by GitHub
parent 7098ddcd19
commit 8ff2785fb9
  1. 7
      scripts/post-commit
  2. 12
      tools/op.sh
  3. 1
      tools/setup.sh

@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -e
if [[ -f .git/hooks/post-commit.d/post-commit ]]; then
.git/hooks/post-commit.d/post-commit
fi
tools/op.sh lint --fast
echo ""

@ -61,6 +61,16 @@ function op_get_openpilot_dir() {
done
}
function op_install_post_commit() {
op_get_openpilot_dir
if [[ ! -d $OPENPILOT_ROOT/.git/hooks/post-commit.d ]]; then
mkdir $OPENPILOT_ROOT/.git/hooks/post-commit.d
mv $OPENPILOT_ROOT/.git/hooks/post-commit $OPENPILOT_ROOT/.git/hooks/post-commit.d 2>/dev/null || true
fi
cd $OPENPILOT_ROOT/.git/hooks
ln -sf ../../scripts/post-commit post-commit
}
function op_check_openpilot_dir() {
echo "Checking for openpilot directory..."
if [[ -f "$OPENPILOT_ROOT/launch_openpilot.sh" ]]; then
@ -327,6 +337,7 @@ function op_default() {
echo -e "${BOLD}${UNDERLINE}Commands [Testing]:${NC}"
echo -e " ${BOLD}sim${NC} Run openpilot in a simulator"
echo -e " ${BOLD}lint${NC} Run the linter"
echo -e " ${BOLD}post-commit${NC} Install the linter as a post-commit hook"
echo -e " ${BOLD}test${NC} Run all unit tests from pytest"
echo ""
echo -e "${BOLD}${UNDERLINE}Options:${NC}"
@ -372,6 +383,7 @@ function _op() {
replay ) shift 1; op_replay "$@" ;;
sim ) shift 1; op_sim "$@" ;;
install ) shift 1; op_install "$@" ;;
post-commit ) shift 1; op_install_post_commit "$@" ;;
* ) op_default "$@" ;;
esac
}

@ -158,6 +158,7 @@ function git_clone() {
function install_with_op() {
cd $OPENPILOT_ROOT
$OPENPILOT_ROOT/tools/op.sh install
$OPENPILOT_ROOT/tools/op.sh post-commit
LOG_FILE=$(mktemp)

Loading…
Cancel
Save