File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#! /bin/sh
22# Optional: install a pre-push hook that runs ores-lint.
3- # Not installed automatically by the rollout - run this yourself per repo.
4- set -u
5- ROOT=$( git rev-parse --show-toplevel 2> /dev/null) || { echo " not a git repo" ; exit 1; }
6- HOOK=" $ROOT /.git/hooks/pre-push"
7- if [ -e " $HOOK " ] && ! grep -q ' ores-lint' " $HOOK " ; then
8- echo " refusing to clobber an existing pre-push hook: $HOOK "
3+ set -eu
4+ ROOT=$( git rev-parse --show-toplevel 2> /dev/null) || { echo " not a git repo" >&2 ; exit 1; }
5+ HOOKS_PATH=$( git -C " $ROOT " config --get core.hooksPath 2> /dev/null || true)
6+ case " $HOOKS_PATH " in
7+ " " ) GIT_DIR=$( git -C " $ROOT " rev-parse --absolute-git-dir) ; HOOK_DIR=" $GIT_DIR /hooks" ;;
8+ /* ) HOOK_DIR=" $HOOKS_PATH " ;;
9+ ' ~/' * ) HOOK_DIR=" $HOME /${HOOKS_PATH# ??} " ;;
10+ * ) HOOK_DIR=" $ROOT /$HOOKS_PATH " ;;
11+ esac
12+ mkdir -p " $HOOK_DIR "
13+ HOOK=" $HOOK_DIR /pre-push"
14+ if [ -e " $HOOK " ] && ! grep -Fq ' installed by .ores-lint/install-git-hooks.sh' " $HOOK " ; then
15+ echo " refusing to clobber an existing pre-push hook: $HOOK " >&2
916 exit 1
1017fi
1118cat > " $HOOK " << 'INNER '
1219#!/bin/sh
1320# installed by .ores-lint/install-git-hooks.sh
14- [ -x "$(git rev-parse --show-toplevel)/.ores-lint/lint.sh" ] && \
15- sh "$(git rev-parse --show-toplevel)/.ores-lint/lint.sh"
16- exit 0
21+ set -eu
22+ ROOT=$(git rev-parse --show-toplevel 2>/dev/null) || exit 1
23+ LINT="$ROOT/.ores-lint/lint.sh"
24+ if [ ! -x "$LINT" ]; then
25+ echo "ores-lint pre-push: missing executable $LINT" >&2
26+ exit 1
27+ fi
28+ exec sh "$LINT"
1729INNER
1830chmod +x " $HOOK "
1931echo " installed $HOOK "
You can’t perform that action at this time.
0 commit comments