diff --git a/README.md b/README.md index bcc61084..ebc6e7bd 100644 --- a/README.md +++ b/README.md @@ -272,11 +272,20 @@ You could have chosen to install as a global hook template or at a single reposi Please follow the steps below based on which option you had chosen at installation. ## Uninstallation from a global hook template -To uninstall talisman globally from your machine, run: +Run the following command on your terminal to uninstall talisman globally from your machine. + +For pre-commit hook: ``` curl --silent https://raw.githubusercontent.com/thoughtworks/talisman/master/global_install_scripts/uninstall.bash > /tmp/uninstall_talisman.bash && /bin/bash /tmp/uninstall_talisman.bash ``` + +For pre-push hook: + +``` +curl --silent https://raw.githubusercontent.com/thoughtworks/talisman/master/global_install_scripts/uninstall.bash > /tmp/uninstall_talisman.bash && /bin/bash /tmp/uninstall_talisman.bash pre-push +``` + This will 1. ask you for the base dir of all your repos, find all git repos inside it and remove talisman hooks diff --git a/global_install_scripts/install.bash b/global_install_scripts/install.bash index e8940bc5..05b47696 100755 --- a/global_install_scripts/install.bash +++ b/global_install_scripts/install.bash @@ -295,7 +295,7 @@ function run() { EXCEPTIONS_FILE=${TEMP_DIR}/pre-existing-hooks.paths touch ${EXCEPTIONS_FILE} - CMD_STRING="${SUDO_PREFIX} ${SEARCH_CMD} ${SEARCH_ROOT} ${EXTRA_SEARCH_OPTS} -name .git -type d -exec ${REPO_HOOK_SETUP_SCRIPT_PATH} ${TALISMAN_HOOK_SCRIPT_PATH} ${EXCEPTIONS_FILE} {} \;" + CMD_STRING="${SUDO_PREFIX} ${SEARCH_CMD} ${SEARCH_ROOT} ${EXTRA_SEARCH_OPTS} -name .git -type d -exec ${REPO_HOOK_SETUP_SCRIPT_PATH} ${TALISMAN_HOOK_SCRIPT_PATH} ${EXCEPTIONS_FILE} {} ${HOOK_SCRIPT} \;" echo_debug "EXECUTING: ${CMD_STRING}" eval "${CMD_STRING}" || true @@ -351,7 +351,7 @@ END_OF_SCRIPT setup_talisman fi - echo "Setting up pre-commit hook in git template directory" + echo "Setting up ${HOOK_SCRIPT} hook in git template directory" setup_git_template_talisman_hook echo echo "Setting up talisman hook recursively in git repos" diff --git a/global_install_scripts/setup_talisman_hook_in_repo.bash b/global_install_scripts/setup_talisman_hook_in_repo.bash index 9d2995d2..a3df19f5 100644 --- a/global_install_scripts/setup_talisman_hook_in_repo.bash +++ b/global_install_scripts/setup_talisman_hook_in_repo.bash @@ -6,6 +6,7 @@ function run() { TALISMAN_HOOK_SCRIPT_PATH=$1 EXCEPTIONS_FILE=$2 DOT_GIT_DIR=$3 + HOOK_SCRIPT=$4 function echo_error() { echo -ne $(tput setaf 1) >&2 @@ -26,7 +27,7 @@ function run() { echo -ne $(tput sgr0) } - REPO_HOOK_SCRIPT=${DOT_GIT_DIR}/hooks/pre-commit + REPO_HOOK_SCRIPT=${DOT_GIT_DIR}/hooks/${HOOK_SCRIPT} #check if a hook already exists if [ -e "${REPO_HOOK_SCRIPT}" ]; then #check if already hooked up to talisman @@ -39,7 +40,7 @@ function run() { echo ${DOT_GIT_DIR} | sed 's#/.git$##' >> ${EXCEPTIONS_FILE} fi else - echo "Setting up pre-commit hook in ${DOT_GIT_DIR}/hooks" + echo "Setting up ${HOOK_SCRIPT} hook in ${DOT_GIT_DIR}/hooks" mkdir -p ${DOT_GIT_DIR}/hooks || (echo_error "Could not create hooks directory" && return) LN_FLAGS="-sf" [ -n "true" ] && LN_FLAGS="${LN_FLAGS}v" @@ -48,9 +49,9 @@ function run() { "MINGW32_NT-10.0-WOW" | "MINGW64_NT-10.0") DOT_GIT_DIR_WIN=$(sed -e 's/\/\([a-z]\)\//\1:\\/' -e 's/\//\\/g' <<< "$DOT_GIT_DIR") TALISMAN_HOOK_SCRIPT_PATH_WIN=$(sed -e 's/\/\([a-z]\)\//\1:\\/' -e 's/\//\\/g' <<< "$TALISMAN_HOOK_SCRIPT_PATH") - cmd <<< "mklink /H "${DOT_GIT_DIR_WIN}\\hooks\\pre-commit" "${TALISMAN_HOOK_SCRIPT_PATH_WIN}"" > /dev/null;; + cmd <<< "mklink /H "${DOT_GIT_DIR_WIN}\\hooks\\${HOOK_SCRIPT}" "${TALISMAN_HOOK_SCRIPT_PATH_WIN}"" > /dev/null;; *) - ln ${LN_FLAGS} ${TALISMAN_HOOK_SCRIPT_PATH} ${DOT_GIT_DIR}/hooks/pre-commit + ln ${LN_FLAGS} ${TALISMAN_HOOK_SCRIPT_PATH} ${DOT_GIT_DIR}/hooks/${HOOK_SCRIPT} ;; esac diff --git a/global_install_scripts/uninstall.bash b/global_install_scripts/uninstall.bash index f0fa664e..636e1912 100755 --- a/global_install_scripts/uninstall.bash +++ b/global_install_scripts/uninstall.bash @@ -4,7 +4,11 @@ shopt -s extglob DEBUG=${DEBUG:-''} -declare HOOK_SCRIPT='pre-commit' # TODO: need ability to uninstall pre-push hook as well. +declare HOOK_SCRIPT='pre-commit' +if [[ $# -gt 0 && $1 =~ pre-push.* ]] ; then + HOOK_SCRIPT='pre-push' +fi + function run() { # Arguments: $1 = 'pre-commit' or 'pre-push'. whether to set talisman up as pre-commit or pre-push hook : TODO: not implemented yet # Environment variables: