Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(install) add option to download the binary only and not install a hook #420

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you also looked at how the uninstallation would behave? Would any code changes need to be made to the uninstallation process?


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="";;
*)
tinamthomas marked this conversation as resolved.
Show resolved Hide resolved
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