Listen to git hooks, and trigger your functions simply with gitTA.
import gitTA as git
@git.listen('pre-push')
def run_tests(*args, **kwargs):
import test
test.all_your_things()
if test.failed:
raise BaseException('abort the push' + test.feedback)
With the above code in main.py, the function run_tests will trigger each time git push is called, with the option to abort the push by raising an error. In fact, you can listen to all local git hooks, including:
- pre-commit
- commit-msg
- post-commit
- post-checkout
- .... and many more!
With these hooks, its possible to:
- Encrypt a commit message after user input
- Abort pushes if the branch is master
- Correct file-permissions after branch changes
- Undo branch changes to always stay on master
- Change files after committing
- Most anything good or evil... use your powers responsibly
To install gitTA, copy gitTA into a local git repo of your choice. Edit main.py to your liking, then run the install script (located in ./bash/install_githooks.sh), which will move gitTA into your .git directory, overwriting any current hooks with its own. gitTA is local only -- the install script MUST be run each time another user clones your repository. In short, it's a local tool that must be installed by the user; there is no way to have gitTA pre-installed in a repository, short of passing it around in a zipfile or setting it up as a git template. You can, however, include gitTA in your repository as a visible folder and ask that the user run the install script prior to using it.