Constant TEMPLATE

Source
const TEMPLATE: &str = r#"
#!/bin/sh

set -e

###############################################################################
#          ANY MODIFICATIONS MADE TO THIS FILE WILL GET OVERWRITTEN!          #
###############################################################################

# This file is generated (and re-generated) by `cargo xtask`.
#
# To opt-out of automatic updates, it is sufficient to delete the following
# CONFIG variable, and `cargo xtask` will no longer overwrite this file.

CONFIG=$(cat << <<CONFIG_HEREDOC>>
<<CONFIG>>
<<CONFIG_HEREDOC>>
)

# The rest of the script is the "minimum-viable-bash" required to do 2 things:
#
# 1. Invoke `cargo xtask hook <hook-kind>`.
# 2. Encode the $CONFIG blob that gets passed to the xtask, which contains the
#    user-specified hook configuration (as specified via `install-git-hooks`)
#
# Any future additions to `xtask`-driven hooks should be done in Rust (as
# opposed to extending this bash script)

cd "${GIT_DIR-$(git rev-parse --git-dir)}/.."

XTASK="cargo xtask"

USE_PREBUILT_XTASK="<<USE_PREBUILT_XTASK>>"
if [ -n "$USE_PREBUILT_XTASK" ] && [ -f "<<XTASK_PATH_FILE>>" ]; then
    XTASK=$(cat "<<XTASK_PATH_FILE>>")
fi

$XTASK hook <<HOOK_KIND>> $CONFIG

"#;