{"id":13590838,"url":"https://github.com/swellaby/captain-githook","last_synced_at":"2025-08-28T09:09:58.853Z","repository":{"id":54553091,"uuid":"145181356","full_name":"swellaby/captain-githook","owner":"swellaby","description":"git hook utility for Go codebases","archived":false,"fork":false,"pushed_at":"2021-10-20T03:24:37.000Z","size":279,"stargazers_count":31,"open_issues_count":11,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T08:35:41.210Z","etag":null,"topics":["git","git-hooks","githook","githooks-plugin","go","golang","hook-manager","hooks"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swellaby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-18T01:48:52.000Z","updated_at":"2024-10-18T22:26:19.000Z","dependencies_parsed_at":"2022-08-13T19:30:50.813Z","dependency_job_id":null,"html_url":"https://github.com/swellaby/captain-githook","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swellaby%2Fcaptain-githook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swellaby%2Fcaptain-githook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swellaby%2Fcaptain-githook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swellaby%2Fcaptain-githook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swellaby","download_url":"https://codeload.github.com/swellaby/captain-githook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248952345,"owners_count":21188427,"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","githook","githooks-plugin","go","golang","hook-manager","hooks"],"created_at":"2024-08-01T16:00:50.954Z","updated_at":"2025-04-14T20:21:29.511Z","avatar_url":"https://github.com/swellaby.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# captain-githook \nCross-platform, configurable, git hook utility geared for Go codebases.  \n\n****** Functional, but still in Beta ****** \n\n[![Linux CI Badge][linux-ci-badge]][linux-ci-url]\n[![Mac CI Badge][mac-ci-badge]][mac-ci-url]\n[![Windows CI Badge][windows-ci-badge]][windows-ci-url]  \n\n[![Test Results Badge][tests-badge]][sonar-tests-url]\n[![Coverage Badge][coverage-badge]][coverage-url]\n[![Sonar Quality Gate Badge][sonar-quality-gate-badge]][sonar-url]  \n\n## Contents\n* [About](#about)\n* [Installation](#installation)\n* [Getting Started](#getting-started)\n* [Configure](#configure)\n    * [Supported Git Hooks][supported-hooks-section]\n    * [Allowed Config File Names][config-file-names-section]\n* [Remove](#remove)\n\n\n## About\nGit hooks are scripts/commands that git can execute on certain events which helps you automate tasks, enforce quality and consistency in your code, and more. `captain-githook` allows you to utilize any and all git hooks in your repository (`commit-msg`, `pre-commit`, `pre-push`, etc.) via a simple configuration file. \n\nYes, there are other git hook utilities out there (in fact we love, recommend, and use [husky][husky-url] in our JavaScript/TypeScript projects that use [npm][npm-url]). However, we made `captain-githook` because we wanted a git hook utility for our Go codebases that was cross-platform, easily configurable, and that wasn't *dependent* on another, non-Go framework/runtime.\n\n## Installation\nWe'll be adding binary releases shortly, but for now you'll need to have your [Go][go-download-url] environment setup and use `go get` i.e.:\n\n```sh\ngo get -u github.com/swellaby/captain-githook\n```\n\nNote that the latest `captain-githook` version requires Go 1.12 or higher. If you need to use `captain-githook` on Go 1.11 and earlier, make sure you use the `v0.0.7` tag:\n\n```sh\ngo get -u github.com/swellaby/captain-githook@v0.0.7\n```\n\nThis will ensure that the captain-githook executable is available on your system for initializing your repositories (creating git hook and config files) as well as for executing your defined hook scripts.\n\n## Getting Started\nRun the `init` sub-command within a git repository to create the git hook files and create the `captain-githook` config file:\n\n```sh\ncaptain-githook init\n```\n\nIf you'd prefer to use a different name for the config file, you can specify your desired config file name as a flag (`--config-filename` or `--f`) on the `init` command. For example:\n\n```sh\ncaptain-githook init --config-filename .captain-githookrc.json\n```\n\nSee [allowed config file names][config-file-names-section] below for info on what config file names you can use.\n\n## Configure\nYou specify which scripts/commands you want to run for each git hook in the `captain-githook` configuration file included in your repository.\n\nThe captain-githook config is a json formatted file (we'll consider supporting other formats like yaml or toml if there's enough interest) and must be named with one of the [allowed file names][config-file-names-section].  \n\nJust ensure there's a `hooks` object key, and then for every git hook you want to run, add a key with the hook name (see [supported hooks][supported-hooks-section] for allowed hook names) and the script/command you want to run.\n\n```json\n// captaingithook.json\n{\n    \"hooks\": {\n        \"pre-commit\": \"golint ./...\",\n        \"pre-push\": \"go test ./...\"\n    }\n}\n```\n\n### Supported Hooks\n`captain-githook` supports all the below git hooks:\n\n- `applypatch-msg`\n- `pre-applypatch`\n- `post-applypatch`\n- `pre-commit`\n- `prepare-commit-msg`\n- `commit-msg`\n- `post-commit`\n- `pre-rebase`\n- `post-checkout`\n- `post-merge`\n- `pre-receive`\n- `update`\n- `post-receive`\n- `post-update`\n- `pre-auto-gc`\n- `post-rewrite`\n- `pre-push`\n\n### Config File Names\nThere are several supported names you can use for your config file:\n\n- `captaingithook.json`\n- `.captaingithook.json`\n- `captaingithookrc`\n- `.captaingithookrc`\n- `captaingithookrc.json`\n- `.captaingithookrc.json`\n- `captain-githook.json`\n- `.captain-githook.json`\n- `captain-githookrc`\n- `.captain-githookrc`\n- `captain-githookrc.json`\n- `.captain-githookrc.json`\n\n## Remove\nNot yet implemented\n\n\u003cbr /\u003e  \n\n[Back to top][top-section]\n\n[githooks-docs-url]: https://git-scm.com/docs/githooks\n[go-download-url]: https://golang.org/dl/\n[husky-url]: https://www.npmjs.com/package/husky\n[npm-url]: https://www.npmjs.com/get-npm\n[config-file-names-section]: #config-file-names\n[supported-hooks-section]: #supported-hooks\n[top-section]: #captain-githook\n[linux-ci-badge]: https://img.shields.io/azure-devops/build/swellaby/opensource/123/master.svg?label=linux%20build\u0026style=flat-square\n[linux-ci-url]: https://dev.azure.com/swellaby/OpenSource/_build/latest?definitionId=123\n[mac-ci-badge]: https://img.shields.io/azure-devops/build/swellaby/opensource/124/master.svg?label=mac%20build\u0026style=flat-square\n[mac-ci-url]: https://dev.azure.com/swellaby/OpenSource/_build/latest?definitionId=124\n[windows-ci-badge]: https://img.shields.io/azure-devops/build/swellaby/opensource/125/master.svg?label=windows%20build\u0026style=flat-square\n[windows-ci-url]: https://dev.azure.com/swellaby/OpenSource/_build/latest?definitionId=125\n[coverage-badge]: https://img.shields.io/azure-devops/coverage/swellaby/opensource/123/master.svg?style=flat-square\n[coverage-url]: https://codecov.io/gh/swellaby/captain-githook\n[tests-badge]: https://img.shields.io/azure-devops/tests/swellaby/opensource/123/master.svg?label=unit%20tests\u0026style=flat-square\n[sonar-quality-gate-badge]: https://img.shields.io/sonar/quality_gate/swellaby:captain-githook?server=https%3A%2F%2Fsonarcloud.io\u0026style=flat-square\n[sonar-url]: https://sonarcloud.io/dashboard?id=swellaby%3Acaptain-githook\n[sonar-tests-url]: https://sonarcloud.io/component_measures?id=swellaby%3Acaptain-githook\u0026metric=tests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswellaby%2Fcaptain-githook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswellaby%2Fcaptain-githook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswellaby%2Fcaptain-githook/lists"}