Package: autohooks
AutohooksLibrary for managing and writinggit hooksin Python usingpyproject.tomlfor its settings.Looking for automatic formatting and linting, e.g., withblackandruff,
while creating a git commit using a pure Python implementation? Do you just want
to have your git hook settings in thepyproject.tomlfile too?Welcome toautohooks!Why?SolutionRequirementsPluginsInstalling autohooksCommand CompletionSetup for bashSetup for zshMaintainerContributingLicenseWhy?Several outstanding libraries for managing and executing git hooks exist already.
To name a few:husky,lint-staged,precise-commitsorpre-commit.However, they need another interpreter besides python (like husky), require a
different config file besidespyproject.tomlor are too ambiguous (like
pre-commit). pre-commit is written in python but has support hooks written in
all kind of languages. Additionally, it maintains the dependencies by itself and
does not install them in the current environment.Solutionautohooks is a pure python library that installs a minimalexecutable git hook.
It allows the decision of how to maintain the hook dependencies
by supporting different modes and stores its settings in the well knownpyproject.tomlfile.RequirementsPython 3.9+ is required for autohooks.PluginsPython code formatting viablackPython code formatting viaautopep8Python code linting viaruffPython code linting viapylintPython code linting viaflake8Python code linting viamypyPython import sorting viaisortRunning tests viapytestInstalling autohooksQuick installation ofruffandblackplugins usingpoetry:poetryadd--devautohooksautohooks-plugin-blackautohooks-plugin-ruff
poetryrunautohooksactivate--modepoetry
poetryrunautohookspluginsaddautohooks.plugins.blackautohooks.plugins.ruffThe output ofautohooks activateshould be similar to✓ autohooks pre-commit hook installed at /autohooks-test/.git/hooks/pre-commit using poetry mode.Autohooks has an extensible plugin model. Each plugin provides different
functionality which often requires to install additional dependencies.For managing these dependencies currently three modes are supported by
autohooks:pythonpathfor dependency management viapippoetryfor dependency management viapoetry(recommended)pipenvfor dependency management viapipenvThese modes handle how autohooks, the plugins and their dependencies are loaded
during git hook execution.If no mode is specified in thepyproject.tomlconfig fileand no mode is set duringactivation, autohooks
will use thepythonpath modeby default.For more details on usingpip,poetryorpipenvin conjunction with these
modes see thedocumentation.Command Completionautohookscomes with support for command line completion in bash
and zsh.Setup for bashecho"source ~/.autohooks-complete.bash">>~/.bashrc
autohooks--print-completionbash>~/.autohooks-complete.bashAlternatively, you can use the result of the completion command directly with
the eval function of your bash shell:eval"$(autohooks--print-completionbash)"Setup for zshecho'fpath=("$HOME/.zsh.d" $fpath)'>>~/.zsh
mkdir-p~/.zsh.d/
autohooks--print-completionzsh>~/.zsh.d/_autohooksAlternatively, you can use the result of the completion command directly with
the eval function of your zsh shell:eval"$(autohooks--print-completionzsh)"MaintainerThis project is maintained byGreenbone AG.ContributingYour contributions are highly appreciated. Pleasecreate a pull requeston GitHub. Bigger changes need to be discussed with the development team via theissues section at GitHubfirst.LicenseCopyright (C) 2019 - 2024Greenbone AGLicensed under theGNU General Public License v3.0 or later.