-
Couldn't load subscription status.
- Fork 2
Home
Samuel Voeller edited this page Mar 6, 2025
·
8 revisions
wget -O githooked https://github.com/xCykrix/githooked/releases/download/v2.1.0/githookedgithooked - Manage git hooks across your project with cross-platform support and mobility. Comfortably integrates with git to allow custom scripting. Designed for Bash 4.0 or compatible. Compatible with Git SCM (Git for Windows).
Usage:
githooked [OPTIONS] COMMAND
githooked [COMMAND] --help | -h
githooked --version | -v
Commands:
install Install githooked runtime on the current path. Requires './.git/' to be present.
generate Generate default githooked 'no-op' placeholder hooks.
Global Options:
--trace, -t
Print additional information and details.
--quiet, -q (repeatable)
Suppress informational messages and details.
--help, -h
Show this help
--version, -v
Show version number
Examples:
./githooked --help
./githooked install
./githooked generate prepare-commit-msg pre-commit pre-push
Creating a script with githooked is designed to be a simple, straightforward, and consistent process. To begin creating a script, please review the git hooks list available with Git-SCM. For our example, we will create a pre-commit hook that will require source code tests to pass.
- Create a file named
pre-commitin the.git-hooksfolder. This file will be generated on the first install. - If needed, use the following template to prepare the file.
#!/usr/bin/env bash
# Configure the hook with these options.
HOOK_DEBUG=0 # Set to 1 to enable debug mode. This will print additional output.
HOOK_DISABLE_NOTICE=0 # Set to 1 to disable the notice when the hook exits with an error code.
# Import the git-hooked wrapper to prepare the env and execute the script below.
. "$(dirname "$0")/_util/git-hooked.sh"
# Your script begins here.
# The last command to run, or explicit "exit" commands, will determine the status code to Git.
# echo "Placeholder git-hook for pre-commit."
exit 0- Add the validation code between "Your script begins here." and the "exit 0". For this example, we will use a Deno task.
# Your script begins here.
# The last command to run, or explicit "exit" commands, will determine the status code to Git.
# do something
exit 0- Add files and run a commit. You should now see the commands defined above have been executed.