{"id":13722390,"url":"https://github.com/dirk/quickhook","last_synced_at":"2025-07-20T20:05:24.641Z","repository":{"id":57526775,"uuid":"66737553","full_name":"dirk/quickhook","owner":"dirk","description":"Faster Git hook runner","archived":false,"fork":false,"pushed_at":"2024-10-19T04:30:05.000Z","size":106,"stargazers_count":62,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-10T05:04:32.362Z","etag":null,"topics":["git","git-hooks","golang","hooks","pre-commit"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dirk.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-27T22:05:25.000Z","updated_at":"2024-10-19T04:30:07.000Z","dependencies_parsed_at":"2024-02-10T09:24:50.407Z","dependency_job_id":"835bc7af-fa7c-4296-a729-8553c7dbdca0","html_url":"https://github.com/dirk/quickhook","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/dirk/quickhook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirk%2Fquickhook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirk%2Fquickhook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirk%2Fquickhook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirk%2Fquickhook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dirk","download_url":"https://codeload.github.com/dirk/quickhook/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirk%2Fquickhook/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266189677,"owners_count":23890065,"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":["git","git-hooks","golang","hooks","pre-commit"],"created_at":"2024-08-03T01:01:28.137Z","updated_at":"2025-07-20T20:05:24.621Z","avatar_url":"https://github.com/dirk.png","language":"Go","readme":"# quickhook\n\n![Build Status](https://github.com/dirk/quickhook/actions/workflows/push.yml/badge.svg)\n[![codecov](https://codecov.io/github/dirk/quickhook/branch/main/graph/badge.svg?token=FRMS9TRJ93)](https://app.codecov.io/github/dirk/quickhook)\n\nQuickhook is a Git hook runner designed for speed. It is opinionated where it matters: hooks are executables organized by directory and must exit with a non-zero code on error. Everything else is up to you!\n\n## Installation\n\n### `go install`\n\nIf you have your $PATH set up for Go then it's as simple as:\n\n```sh\n$ go install github.com/dirk/quickhook\n$ quickhook --version\n1.5.0\n```\n\nTo uninstall use `clean -i`:\n\n```sh\n$ go clean -i github.com/dirk/quickhook\n```\n\n### Homebrew\n\nIf you're on Mac there is a [Homebrew tap for Quickhook](https://github.com/dirk/homebrew-quickhook):\n\n```sh\n$ brew tap dirk/quickhook\n==\u003e Tapping dirk/quickhook\n...\nTapped 1 formula (14 files, 12.6KB).\n\n$ brew install quickhook\n==\u003e Fetching dirk/quickhook/quickhook\n==\u003e Downloading https://github.com/dirk/quickhook/archive/v1.5.0.tar.gz\n...\n/opt/homebrew/Cellar/quickhook/1.5.0: 5 files, 3.1MB, built in 2 seconds\n```\n\n### Linux\n\nInstallable debs and RPMs are available for the [latest release](https://github.com/dirk/quickhook/releases/latest).\n\n```sh\n# Installing a .deb\nwget https://github.com/dirk/quickhook/releases/download/v1.5.0/quickhook-1.5.0-amd64.deb\nsudo apt install ./quickhook-1.5.0-amd64.deb\n\n# Installing a .rpm\nwget https://github.com/dirk/quickhook/releases/download/v1.5.0/quickhook-1.5.0-amd64.rpm\nsudo rpm --install quickhook-1.5.0-amd64.rpm\n```\n\n## Usage\n\nFirst you'll need to install Quickhook in your repository: `quickhook install` command will discover hooks defined in the `.quickhook` directory and create Git hook shims for those. For example, the below is what you can expect from running installation in this repository:\n\n```sh\n$ quickhook install\nCreate file .git/hooks/commit-msg? [yn] y\nInstalled shim .git/hooks/commit-msg\nCreate file .git/hooks/pre-commit? [yn] y\nInstalled shim .git/hooks/pre-commit\n```\n\nQuickhook provides some options to run various hooks directly for development and testing. This way you don't have to follow the whole Git commit workflow just to exercise the new hook you're working on.\n\n```sh\n# Run the pre-commit hooks on all Git-tracked files in the repository\n$ quickhook hook pre-commit --all\n\n# Run them on just one or more files\n$ quickhook hook pre-commit --files=hooks/commit_msg.go,hooks/pre_commit.go\n```\n\nYou can see all of the options by passing `--help` to the sub-command:\n\n```sh\n$ quickhook hook pre-commit --help\n...\nOPTIONS:\n   --all, -a    Run on all Git-tracked files\n   --files, -F  Run on the given comma-separated list of files\n```\n\n## Writing hooks\n\nQuickhook will look for hooks in a corresponding sub-directory of the `.quickhook` directory in your repository. For example, it will look for pre-commit hooks in `.quickhook/pre-commit/`. A hook is any executable file in that directory.\n\n### pre-commit\n\nPre-commit hooks receive the list of staged files separated by newlines on stdin. They are expected to write their result to stdout/stderr (Quickhook doesn't care). If they exit with a non-zero exit code then the commit will be aborted and their output displayed to the user. See the [`go-vet`](.quickhook/pre-commit/go-vet) file for an example.\n\n**Note**: Pre-commit hooks will be executed in parallel and should not mutate the local repository state. For this reason `git` is shimmed on the hooks' $PATH to be unavailable for all but the safest commands. The shim is implemented [here](./hooks/pre_commit_git_shim.sh).\n\n#### Mutating hooks\n\nYou can also add executables to `.quickhook/pre-commit-mutating/`. These will be run _sequentially_, without Git shimmed, and may mutate the local repository state.\n\n#### Suggested formatting\n\nIf you're unsure how to format your lines, there's an informal Unix convention which is already followed by many programming languages, linters, and so forth.\n\n```\nsome/directory/and/file.go:123: Something doesn't look right\n```\n\nA more formal definition of an error line is:\n\n- Sequence of characters representing a valid path\n- A colon (`:`) character\n- Integer of the line where the error occurred\n- A colon character followed by a space character\n- Any printable character describing the error\n- A newline (`\\n`) terminating the error line\n\n### commit-msg\n\nCommit-message hooks are run sequentially. They receive a single argument: a path to a temporary file containing the message for the commit. If they exit with a non-zero exit code the commit will be aborted and any stdout/stderr output displayed to the user.\n\nGiven that they are run sequentially, `commit-msg` hooks are allowed to mutate the commit message temporary file.\n\n## Performance\n\nQuickhook is designed to be as fast and lightweight as possible. There are a few guiding principles for this:\n\n- Ship as a small, self-contained executable.\n- No configuration.\n- Do as much as possible in parallel.\n\n### Tracing\n\nSet `QUICKHOOK_TRACE=1` (or pass `--trace`) to enable tracing during hook execution:\n\n```sh\n$ QUICKHOOK_TRACE=1 git commit ...\nTraced 3 span(s):\ngit diff 4ms\ngit shim 473ns\nhook pre-commit go-vet 238ms\nTraced 1 span(s):\nhook commit-msg trailing-whitespace 3ms\n...\n```\n\n## Contributing\n\nContributions are welcome. If you want to use the locally-built version of Quickhook in the Git hooks, there's a simple 3-line script that will set that up:\n\n```sh\n$ ./scripts/install.sh\nInstalled shim .git/hooks/commit-msg\nInstalled shim .git/hooks/pre-commit\n```\n\nBuilding and testing should be straightforward:\n\n```sh\n# Build a quickhook executable:\n$ go build\n\n# Run all tests:\n$ go test ./...\n```\n\n**Warning**: Many of the tests are integration-style tests which depend on a locally-built Quickhook executable. If you see unexpected test failures, please first try running `go build` before you rerun tests.\n\nThere's also a script that will generate and open an HTML page with coverage:\n\n```sh\n$ ./scripts/coverage.sh\n```\n\n## License\n\nReleased under the Modified BSD license, see [LICENSE](LICENSE) for details.\n","funding_links":[],"categories":["Tools","Hook management","Go"],"sub_categories":["Comparing workflows"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirk%2Fquickhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdirk%2Fquickhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirk%2Fquickhook/lists"}