File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -eu
3+ SOURCE_DIR=$( CDPATH= cd -- " $( dirname -- " $0 " ) " && pwd)
4+ TMP_ROOT=$( mktemp -d " ${TMPDIR:-/ tmp} /ores-lint-hooks.XXXXXX" )
5+ trap ' rm -rf "$TMP_ROOT"' EXIT HUP INT TERM
6+ new_repo () {
7+ repo=" $TMP_ROOT /$1 "
8+ mkdir -p " $repo /.ores-lint"
9+ git -C " $repo " init -q
10+ cp " $SOURCE_DIR /install-git-hooks.sh" " $repo /.ores-lint/install-git-hooks.sh"
11+ printf ' %s\n' ' #!/bin/sh' ' : > "$(git rev-parse --show-toplevel)/lint-ran"' > " $repo /.ores-lint/lint.sh"
12+ chmod +x " $repo /.ores-lint/lint.sh"
13+ printf ' %s\n' " $repo "
14+ }
15+ repo=$( new_repo default)
16+ (cd " $repo " && sh .ores-lint/install-git-hooks.sh && hook=" $( git rev-parse --absolute-git-dir) /hooks/pre-push" && test -x " $hook " && " $hook " && test -f lint-ran)
17+ repo=$( new_repo relative)
18+ (cd " $repo " && git config core.hooksPath .githooks && sh .ores-lint/install-git-hooks.sh && test -x .githooks/pre-push && .githooks/pre-push && test -f lint-ran && test ! -e " $( git rev-parse --absolute-git-dir) /hooks/pre-push" )
19+ repo=$( new_repo absolute)
20+ absolute_hooks=" $TMP_ROOT /absolute-hooks"
21+ (cd " $repo " && git config core.hooksPath " $absolute_hooks " && sh .ores-lint/install-git-hooks.sh && test -x " $absolute_hooks /pre-push" )
22+ repo=$( new_repo tilde)
23+ mkdir -p " $TMP_ROOT /home"
24+ (cd " $repo " && HOME=" $TMP_ROOT /home" git config core.hooksPath ' ~/custom-hooks' && HOME=" $TMP_ROOT /home" sh .ores-lint/install-git-hooks.sh && test -x " $TMP_ROOT /home/custom-hooks/pre-push" )
25+ repo=$( new_repo conflict)
26+ (cd " $repo " && git config core.hooksPath .githooks && mkdir -p .githooks && printf ' %s\n' ' #!/bin/sh' ' echo existing' > .githooks/pre-push && chmod +x .githooks/pre-push && before=$( cat .githooks/pre-push) && if sh .ores-lint/install-git-hooks.sh; then exit 1; fi && test " $( cat .githooks/pre-push) " = " $before " )
27+ printf ' %s\n' ' ores-lint Git hook installer contract: PASS'
You can’t perform that action at this time.
0 commit comments