Skip to content

A very, very small Git hook manager with focus on automation

License

Notifications You must be signed in to change notification settings

Autohook/Autohook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Autohook

Autohook is a very, very small Git hook manager with focus on automation.

It consists of one script which acts as the entry point for all the hooks, and which runs scripts based on symlinks in appropriate directories.

Example

Let's say you have a script to remove .pyc files that you want to run after every git checkout and before every git commit, and another script that runs your test suite that you want to run before every git commit.

Here's the overview of steps:

  1. Install autohook.sh to a directory of your liking.
  2. Put your scripts in:
  • alternative 1: the hooks directory next to the autohook.sh script.
  • alternative 2: a custom directory pointed to by the AUTOHOOK_HOOKS_DIR environment variable
  1. Make sure said scripts are executable (e.g., chmod -R +x hooks/)
  2. Run autohook.sh with the install parameter (e.g., ./autohook.sh install).
  3. Make directories for your hook types (e.g., mkdir -p hooks/post-checkout hooks/pre-commit).
  4. Symlink your scripts to the correct directories, using numbers in symlink names to enforce execution order (e.g., ln -s $PWD/hooks/scripts/delete-pyc-files.sh hooks/post-checkout/01-delete-pyc-files, etc.).
  • Alternatively, you could place your scripts directly under hooks/post-checkout, etc

The result should be a tree that looks something like this:

repo_root/
├── hooks/ OR $AUTOHOOK_HOOKS_DIR/
│   ├── post-checkout/
│   │   └── 01-delete-pyc-files     # symlink to hooks/scripts/delete-pyc-files.sh
│   ├── pre-commit/
│   │   ├── 01-delete-pyc-files     # symlink to hooks/scripts/delete-pyc-files.sh
│   │   └── 02-run-tests            # symlink to hooks/scripts/run-tests.sh
│   └── scripts/
│       ├── delete-pyc-files.sh
│       └── run-tests.sh
├── other_dirs/
└── other_files

You're done!

Contributing

Contributions of all sorts are welcome, be they bug reports, patches, or even just feedback. Creating a new issue or pull request is probably the best way to get started.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

License

This software is licensed under the MIT License. Please see the included LICENSE.txt for details.

About

A very, very small Git hook manager with focus on automation

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages