Skip to content

Commit

Permalink
feat(install) add option to download the binary only and not install …
Browse files Browse the repository at this point in the history
…a hook

Related to Issue thoughtworks#419
  • Loading branch information
FelixMarcusMillne committed Mar 4, 2023
1 parent 5ee48f7 commit 8cde88d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@

set -euo pipefail

NO_HOOK_NAME="no-hook"

DEBUG=${DEBUG:-''}
HOOK_NAME="${1:-pre-push}"
case "$HOOK_NAME" in
pre-commit | pre-push) REPO_HOOK_TARGET=".git/hooks/${HOOK_NAME}" ;;
"$NO_HOOK_NAME") REPO_HOOK_TARGET="";;
*)
echo "Unknown Hook name '${HOOK_NAME}'. Please check parameters"
exit 1
Expand Down Expand Up @@ -90,7 +93,7 @@ run() {
exit $E_UNSUPPORTED_ARCH
;;
esac
}
}

binary_arch_suffix() {
declare OS
Expand Down Expand Up @@ -171,6 +174,7 @@ CMD="${PWD}/${TALISMAN_BIN_TARGET} \${DEBUG_OPTS} --githook ${HOOK_NAME}"
[[ -n "\${TALISMAN_DEBUG}" ]] && echo "Executing: \${CMD}"
\${CMD}
EOF

chmod +x "$REPO_HOOK_TARGET"

echo_success "Talisman successfully installed to '$REPO_HOOK_TARGET'."
Expand Down Expand Up @@ -241,7 +245,10 @@ EOF
echo_success "Talisman successfully installed."
}

if [ ! -d "./.git" ]; then
if [[ "$HOOK_NAME" == "$NO_HOOK_NAME" ]]; then
echo "Requested no hook to be created - installing binary only"
download_and_verify
elif [ ! -d "./.git" ]; then
install_to_git_templates
else
install_to_repo
Expand Down

0 comments on commit 8cde88d

Please sign in to comment.