{"id":13595841,"url":"https://github.com/greenbone/autohooks","last_synced_at":"2026-02-25T10:15:47.519Z","repository":{"id":34213571,"uuid":"169563968","full_name":"greenbone/autohooks","owner":"greenbone","description":"Library for managing git hooks","archived":false,"fork":false,"pushed_at":"2024-04-15T06:20:44.000Z","size":1955,"stargazers_count":183,"open_issues_count":2,"forks_count":21,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-04-17T16:11:16.405Z","etag":null,"topics":["automation","base","devops","formatting","git","githooks-plugin","hooks","linting","pre-commit","pre-commit-hooks","python","python3"],"latest_commit_sha":null,"homepage":"https://greenbone.github.io/autohooks/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/greenbone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-02-07T11:51:20.000Z","updated_at":"2024-04-22T05:31:35.373Z","dependencies_parsed_at":"2023-11-06T07:22:20.867Z","dependency_job_id":"db52457c-6918-44ba-a780-274def6d02b0","html_url":"https://github.com/greenbone/autohooks","commit_stats":{"total_commits":962,"total_committers":18,"mean_commits":53.44444444444444,"dds":0.5530145530145529,"last_synced_commit":"9b0e2360f9d221c7535c6f1b666c0f14ec659ddc"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greenbone%2Fautohooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greenbone%2Fautohooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greenbone%2Fautohooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greenbone%2Fautohooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/greenbone","download_url":"https://codeload.github.com/greenbone/autohooks/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247190255,"owners_count":20898702,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","base","devops","formatting","git","githooks-plugin","hooks","linting","pre-commit","pre-commit-hooks","python","python3"],"created_at":"2024-08-01T16:01:58.979Z","updated_at":"2026-02-25T10:15:47.513Z","avatar_url":"https://github.com/greenbone.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"![Greenbone Logo](https://www.greenbone.net/wp-content/uploads/gb_new-logo_horizontal_rgb_small.png)\n# Autohooks \u003c!-- omit in toc --\u003e\n\n[![PyPI release](https://img.shields.io/pypi/v/autohooks.svg)](https://pypi.org/project/autohooks/)\n[![Build and test Python package](https://github.com/greenbone/autohooks/actions/workflows/ci-python.yml/badge.svg)](https://github.com/greenbone/autohooks/actions/workflows/ci-python.yml)\n[![codecov](https://codecov.io/gh/greenbone/autohooks/branch/main/graph/badge.svg?token=9IX7ucaFwj)](https://codecov.io/gh/greenbone/autohooks)\n\nLibrary for managing and writing [git hooks](https://git-scm.com/docs/githooks)\nin Python using `pyproject.toml` for its settings.\n\nLooking for automatic formatting and linting, e.g., with [black] and [ruff],\nwhile creating a git commit using a pure Python implementation? Do you just want\nto have your git hook settings in the `pyproject.toml` file too?\n\nWelcome to **autohooks**!\n\n- [Why?](#why)\n- [Solution](#solution)\n- [Requirements](#requirements)\n- [Plugins](#plugins)\n- [Installing autohooks](#installing-autohooks)\n- [Command Completion](#command-completion)\n  - [Setup for bash](#setup-for-bash)\n  - [Setup for zsh](#setup-for-zsh)\n- [Maintainer](#maintainer)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Why?\n\nSeveral outstanding libraries for managing and executing git hooks exist already.\nTo name a few: [husky](https://github.com/typicode/husky),\n[lint-staged](https://github.com/okonet/lint-staged),\n[precise-commits](https://github.com/nrwl/precise-commits) or\n[pre-commit](https://github.com/pre-commit/pre-commit).\n\nHowever, they need another interpreter besides python (like husky), require a\ndifferent config file besides `pyproject.toml` or are too ambiguous (like\npre-commit). pre-commit is written in python but has support hooks written in\nall kind of languages. Additionally, it maintains the dependencies by itself and\ndoes not install them in the current environment.\n\n## Solution\n\nautohooks is a pure python library that installs a minimal\n[executable git hook](https://github.com/greenbone/autohooks/blob/main/autohooks/precommit/template).\nIt allows the decision of how to maintain the hook dependencies\nby supporting different modes and stores its settings in the well known\n`pyproject.toml` file.\n\n![Autohooks](https://raw.githubusercontent.com/greenbone/autohooks/main/autohooks.gif)\n\n## Requirements\n\nPython 3.9+ is required for autohooks.\n\n## Plugins\n\n* Python code formatting via [black](https://github.com/greenbone/autohooks-plugin-black)\n\n* Python code formatting via [autopep8](https://github.com/LeoIV/autohooks-plugin-autopep8)\n\n* Python code linting via [ruff](https://github.com/greenbone/autohooks-plugin-ruff)\n\n* Python code linting via [pylint](https://github.com/greenbone/autohooks-plugin-pylint)\n\n* Python code linting via [flake8](https://github.com/greenbone/autohooks-plugin-flake8)\n\n* Python code linting via [mypy](https://github.com/greenbone/autohooks-plugin-mypy)\n\n* Python import sorting via [isort](https://github.com/greenbone/autohooks-plugin-isort)\n\n* Running tests via [pytest](https://github.com/greenbone/autohooks-plugin-pytest/)\n\n## Installing autohooks\n\nQuick installation of [ruff] and [black] plugins using [poetry]:\n\n```shell\npoetry add --dev autohooks autohooks-plugin-black autohooks-plugin-ruff\npoetry run autohooks activate --mode poetry\npoetry run autohooks plugins add autohooks.plugins.black autohooks.plugins.ruff\n```\n\nThe output of `autohooks activate` should be similar to\n```\n ✓ autohooks pre-commit hook installed at /autohooks-test/.git/hooks/pre-commit using poetry mode.\n```\n\nAutohooks has an extensible plugin model. Each plugin provides different\nfunctionality which often requires to install additional dependencies.\n\nFor managing these dependencies currently three modes are supported by\nautohooks:\n\n* `pythonpath` for dependency management via [pip]\n* `poetry` for dependency management via [poetry] (recommended)\n* `pipenv` for dependency management via [pipenv]\n* `uv` for dependency management via [uv]\n\nThese modes handle how autohooks, the plugins and their dependencies are loaded\nduring git hook execution.\n\nIf no mode is specified in the [`pyproject.toml` config file](#configure-mode-and-plugins-to-be-run)\nand no mode is set during [activation](#activating-the-git-hooks), autohooks\nwill use the [pythonpath mode](#pythonpath-mode) by default.\n\nFor more details on using [pip], [poetry] or [pipenv] in conjunction with these\nmodes see the [documentation](https://greenbone.github.io/autohooks).\n\n## Command Completion\n\n`autohooks` comes with support for command line completion in bash\nand zsh.\n\n### Setup for bash\n\n```bash\necho \"source ~/.autohooks-complete.bash\" \u003e\u003e ~/.bashrc\nautohooks --print-completion bash \u003e ~/.autohooks-complete.bash\n```\n\nAlternatively, you can use the result of the completion command directly with\nthe eval function of your bash shell:\n\n```bash\neval \"$(autohooks --print-completion bash)\"\n```\n\n### Setup for zsh\n\n```zsh\necho 'fpath=(\"$HOME/.zsh.d\" $fpath)' \u003e\u003e ~/.zsh\nmkdir -p ~/.zsh.d/\nautohooks --print-completion zsh \u003e ~/.zsh.d/_autohooks\n```\n\nAlternatively, you can use the result of the completion command directly with\nthe eval function of your zsh shell:\n\n```bash\neval \"$(autohooks --print-completion zsh)\"\n```\n\n## Maintainer\n\nThis project is maintained by [Greenbone AG](https://www.greenbone.net/).\n\n## Contributing\n\nYour contributions are highly appreciated. Please\n[create a pull request](https://github.com/greenbone/autohooks/pulls)\non GitHub. Bigger changes need to be discussed with the development team via the\n[issues section at GitHub](https://github.com/greenbone/autohooks/issues)\nfirst.\n\n## License\n\nCopyright (C) 2019 - 2024 [Greenbone AG](https://www.greenbone.net/)\n\nLicensed under the [GNU General Public License v3.0 or later](LICENSE).\n\n[black]: https://black.readthedocs.io/en/stable/\n[pip]: https://pip.pypa.io/en/stable/\n[pipenv]: https://pipenv.readthedocs.io/en/latest/\n[poetry]: https://python-poetry.org/\n[pylint]: https://pylint.readthedocs.io/en/latest/\n[ruff]: https://docs.astral.sh/ruff/\n[uv]: https://docs.astral.sh/uv/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreenbone%2Fautohooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreenbone%2Fautohooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreenbone%2Fautohooks/lists"}