All Projects → datagrok → modular-git-hooks

datagrok / modular-git-hooks

Licence: GPL-3.0 License
A tool for organizing git hooks into directories of modular files.

Programming Languages

shell
77523 projects
Makefile
30231 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to modular-git-hooks

elixir git hooks
🪝 Add git hooks to Elixir projects
Stars: ✭ 98 (+415.79%)
Mutual labels:  git-hook, git-hooks
enforce-git-message
Enforces conventional git commit messages for git repositories
Stars: ✭ 30 (+57.89%)
Mutual labels:  git-hooks
precommit-hook
Automatically check your python code on every commit. 🔍 ✔️
Stars: ✭ 16 (-15.79%)
Mutual labels:  git-hooks
semantic-commit-hook
Git hook that enforces semantic commit messages.
Stars: ✭ 34 (+78.95%)
Mutual labels:  git-hook
captain-git-hook
✅ define git hooks as scripts in your package.json
Stars: ✭ 25 (+31.58%)
Mutual labels:  git-hooks
husky-elixir
🐶 Git hooks made easy
Stars: ✭ 47 (+147.37%)
Mutual labels:  git-hooks
commithelper
A tool to create and lint commit messages
Stars: ✭ 35 (+84.21%)
Mutual labels:  git-hooks
git-conventional-commits
Git Conventional Commits Util to generate Semantic Version and Markdown Change Log and Validate Commit Messag
Stars: ✭ 58 (+205.26%)
Mutual labels:  git-hooks
rusty-hook
git hook manager, geared toward Rust projects
Stars: ✭ 93 (+389.47%)
Mutual labels:  git-hooks
rubocop runner
runs rubocop for changed files, can be used as pre-commit hook
Stars: ✭ 27 (+42.11%)
Mutual labels:  git-hook
git-emojis-hook
Simple git hook to provide strong guidelines for commit message with emojis
Stars: ✭ 46 (+142.11%)
Mutual labels:  git-hook
pre-commit-opa
Pre-commit git hooks for Open Policy Agent (OPA) and Rego development
Stars: ✭ 53 (+178.95%)
Mutual labels:  git-hooks
detect-secrets
A developer-friendly secrets detection tool for CI and pre-commit hooks based on Yelp's detect-secrets
Stars: ✭ 43 (+126.32%)
Mutual labels:  git-hooks
prepare-commit-msg
Automatically prefix commit messages with the current branch issue number
Stars: ✭ 28 (+47.37%)
Mutual labels:  git-hooks
run-if-changed
Run a command if a file changes via Git hooks
Stars: ✭ 25 (+31.58%)
Mutual labels:  git-hooks
pre-commit-hooks-safety
A pre-commit hook to check your Python dependencies against safety-db
Stars: ✭ 69 (+263.16%)
Mutual labels:  git-hooks
modern-office-git-diff
An experiment in tracking and diffing versions of modern Microsoft Office files in Git.
Stars: ✭ 51 (+168.42%)
Mutual labels:  git-hooks
komit
An interactive prompt for conventional commit messages that doesn't get in your way. Designed to run as a git hook.
Stars: ✭ 29 (+52.63%)
Mutual labels:  git-hook
mestral
Simple hook management for Git
Stars: ✭ 55 (+189.47%)
Mutual labels:  git-hooks
php-git-hooks
Git hooks for the local repository of the PHP project
Stars: ✭ 20 (+5.26%)
Mutual labels:  git-hooks

modular-git-hooks

Build Status

Sometimes, you want to perform several different actions in one git hook. For example, you might find several useful pre-commit hooks online, all of which you would like to enable in your git repository.

One fragile way to accomplish this is to copy-and-paste all of the code from those various pre-commit hooks into the single hook that git requires, named hooks/pre-commit. This is, of course, impossible if some of those hooks are implemented in differing languages.

A slightly less-horrible but still-unpleasant mechanism is to create a hooks/pre-commit dispatching script which explicitly invokes each of the hooks you have downloaded and stored in separate files. But then you have to modify that dispatcher every time you update, deal with passing arguments and standard-input to the sub-hooks, and handle their exit statuses correctly.

This repository provides a general-purpose dispatch tool that does all that for you and requires no modification when you add or remove hooks. It gives you a separate directory for each type of git hook, allowing you to keep each hook in its own file. Toss as many hooks as you like into the appropriate directory and they will all be executed, in alphanumeric order, without editing configuration files or launcher-scripts. It uses git config for any configuration needs. It is implemented in dash- and bash-compatible shell script, which, granted, isn't the most pleasant or elegant, but on the other hand means you don't have to worry about your hooks breaking for lack of the correct version of Python, Ruby, or some other language du jour.

BeforeAfter
.git/
└── hooks/
    └── pre-commit*

(Where pre-commit performs formatting, linking, unit testing, and frobnicating)

.git/
└── hooks/
    ├── pre-commit.d/
    │   ├── format-code.sh*
    │   ├── run-linter.py*
    │   ├── unit-tests*
    │   └── frobnicate.rb*
    └── pre-commit -> /path/to/dispatch*

Most hooks intended for standalone use should work, unmodified, when placed within a hook-type directory.

This project contains:

  • The executable script dispatch, which is all that is needed from this project to enable the use of multiple git hooks per git hook type.
  • install-dispatch, which is a little helper script that will get dispatch set up for you.
  • tests/, a set of functional tests to prevent me from breaking this code.
  • hooks/, a collection of optional hooks that work well with dispatch, that you may install where useful. For more information, see the hooks README

Contents

License

Copyright 2014 Michael F. Lamb. This software is released under the terms of the GNU General Public License, version 3 or any later version.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].