Manage your git hooks, and only run the ones you need. Commit a yaml file, and live free!
- 0 runtime dependencies, just a single blob.
- place your .file_hooks.yml file anywhere up your file tree from the git repo.
- concurrently run commands.
- exclude globs
- streaming output for commands instead of catpuring output and adding it later. See this issue
- cd to your git project.
- run
bash <(curl -fsSL https://raw.githubusercontent.com/ericwooley/git_file_hooks/master/install.sh)
or curl into a file, inspect and run that. - (optionally) create .file_hooks.yml with the content
## There will be options, but there aren't yet, so this keyword is reserved
# options:
post-checkout: &BASIC_HOOK_COMMAND
- patterns:
- "**/yarn.lock"
commands:
- yarn;
- patterns:
- "**/package-lock.json"
commands:
- npm i;
- patterns:
- "**/Gemfile"
commands:
- bundle install
- patterns:
- "**/db/migrate/*.rb"
commands:
# each entry is run in parallel, so run these in order.
- rake migrate:data; rake migrate:db;
# YAML has templates, so you can reuse configs.
hooks:
# applypatch-msg: *BASIC_HOOK_COMMAND
# pre-applypatch: *BASIC_HOOK_COMMAND
# post-applypatch: *BASIC_HOOK_COMMAND
# pre-commit: *BASIC_HOOK_COMMAND
# prepare-commit-msg: *BASIC_HOOK_COMMAND
# commit-msg: *BASIC_HOOK_COMMAND
post-commit: *BASIC_HOOK_COMMAND
# pre-rebase: *BASIC_HOOK_COMMAND
# post-checkout: *BASIC_HOOK_COMMAND
# post-merge: *BASIC_HOOK_COMMAND
# pre-push: *BASIC_HOOK_COMMAND
# pre-receive: *BASIC_HOOK_COMMAND
# update: *BASIC_HOOK_COMMAND
# post-receive: *BASIC_HOOK_COMMAND
# post-update: *BASIC_HOOK_COMMAND
# push-to-checkout: *BASIC_HOOK_COMMAND
# pre-auto-gc: *BASIC_HOOK_COMMAND
# post-rewrite: *BASIC_HOOK_COMMAND
# rebase: *BASIC_HOOK_COMMAND
# sendemail-validate: *BASIC_HOOK_COMMAND
# fsmonitor-watchman: *BASIC_HOOK_COMMAND
add SKIP_GIT_HOOKS=1
before your git command to skip tests. EG SKIP_GIT_HOOKS=1 git push
.
You can run the install script with a few enviornment variables for easier upgrades.
OVERWRITE_ALL_HOOKS=true ./install.sh
OVERWRITE_ALL_HOOKS=true NO_HOOK_BACKUPS=true bash <(curl -fsSL https://raw.githubusercontent.com/ericwooley/git_file_hooks/master/install.sh)
Use cargo:1.32.0
The make file has various helpful tasks. It's most of it's integration tests are run against the commits in this repo. Not ideal... but it sure is easy.
make build
will generate a build for your platform.
OVERWRITE_ALL_HOOKS=true NO_HOOK_BACKUPS=true USE_LOCAL=true bash <(curl -fsSL https://raw.githubusercontent.com/ericwooley/git_file_hooks/master/install.sh)
Will install the build from the build/* directory instead of from the latest resease.
-
Push the changes,
make build
and draft a new release usingvX.X.X
where X is the release number. -
Upload the binary, for gnu-linux and osx.
-
Publish the release
-
update the install.sh script version variable to match the released version, otherwise the install script will install the previous version.
-
push the install.sh update to master.
hooks are an array of {patterns: [], commands: []}
The patterns are globs that will be run against the files that changed, if any of them match, the commands will be run (in parallel).
The commands for a pattern are run in parallel, but each command pattern object is run in synchournously, and in order.