{"id":15879977,"url":"https://github.com/ratson/git-guppy-safe","last_synced_at":"2026-05-07T18:44:47.851Z","repository":{"id":143879856,"uuid":"80734330","full_name":"ratson/git-guppy-safe","owner":"ratson","description":null,"archived":false,"fork":false,"pushed_at":"2017-02-02T15:31:12.000Z","size":72,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T00:37:06.275Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/ratson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-MIT","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":"2017-02-02T14:43:10.000Z","updated_at":"2017-02-02T15:31:19.000Z","dependencies_parsed_at":"2023-12-11T00:15:16.921Z","dependency_job_id":null,"html_url":"https://github.com/ratson/git-guppy-safe","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/ratson%2Fgit-guppy-safe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratson%2Fgit-guppy-safe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratson%2Fgit-guppy-safe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratson%2Fgit-guppy-safe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ratson","download_url":"https://codeload.github.com/ratson/git-guppy-safe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246758369,"owners_count":20828919,"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":[],"created_at":"2024-10-06T03:06:57.244Z","updated_at":"2026-05-07T18:44:42.826Z","avatar_url":"https://github.com/ratson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# git-guppy [![NPM version](https://badge.fury.io/js/git-guppy.svg)](http://badge.fury.io/js/git-guppy) [![Build Status](https://travis-ci.org/therealklanni/git-guppy.svg?branch=master)](https://travis-ci.org/therealklanni/git-guppy) [![codecov.io](http://codecov.io/github/therealklanni/git-guppy/coverage.svg?branch=master)](http://codecov.io/github/therealklanni/git-guppy?branch=master) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/therealklanni/git-guppy?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n\n![guppy](guppy.png)\n\n\u003e Simple git-hook integration for your gulp workflows.\n\nguppy streamlines and extends your git-hooks by integrating them with your\n[gulp](http://gulpjs.com) workflow. This enables you to have **gulp tasks that\nrun when triggered by a git-hook**, which means you can do cool things like\nabort a commit if your tests are failing. Git-hooks can now be managed through\n[npm](https://npmjs.org), allowing them to automatically be installed and\nupdated. And because they integrate with gulp, it's easy to modify the workflow\nand even combine hooks with your other gulp tasks.\n\nguppy leverages these powerful existing systems as its backbone, allowing guppy\n(and therefore your git-hooks) to remain as simple and lightweight as possible\nthrough interfaces you're already familiar with.\n\nA git-hook that lint-checks your code and makes sure your unit tests pass before\ncommitting could be as simple as\n\n```js\ngulp.task('pre-commit', ['lint', 'unit']);\n```\n\n## Install\n\n```bash\nnpm i git-guppy --save-dev\n```\n\n## Usage\n\n### Git integration\n\n*Automatic!*\n\nThe actual scripts that git will run to trigger guppy's hooks will be automatically\ninstalled to your `.git/hooks/` directory. These are just a wrapper for invoking\nthe gulp tasks that guppy registers.\n\nTypically, a workflow can be added to your gulp tasks via a *guppy-hook*. A\nguppy-hook is like a git-hook preconfigured for specific gulp workflows.\n\nYou can install *guppy-hooks* via `npm` just like any other package. For every valid\ngit-hook name, there exists a \"guppy-[hookname]\" package that automatically installs\nthe related hook to your `.git/hooks` dir, e.g. \"guppy-pre-commit\" or \"guppy-post-update\".\nJust add the guppy-hook you need as a dev-dependency in your project.\n\nSearch [\"guppy-hook\" on npm](https://www.npmjs.com/search?q=guppy-hook) to find all\nguppy-hook packages. Or run `npm search guppy-hook` from the commandline.\n\n### gulp integration\n\n\u003e :warning: **Stop!** If you are using a guppy-hook package, refer to the\ndocumentation for that package. You do not need the steps below unless you are\nadding custom guppy integration to your gulpfile or authoring your own guppy-hook\npackage.\n\nguppy exposes a few simple methods to help you superpower your git-hooks with\ngulp tasks.\n\nBefore you dive in, initialize guppy by passing in your gulp reference:\n\n```js\nvar gulp = require('gulp');\nvar guppy = require('git-guppy')(gulp);\n```\n\nThen simply define some gulp tasks in your `gulpfile.js` whose names match\nwhichever git-hooks you want to be triggerable by git.\n\n```js\ngulp.task('pre-commit', function () {\n  // see below\n});\n```\n\n*Note: if you are working directly with guppy rather than installing a guppy-hook\nyou will need to manually install the associated git-hooks using the\n[guppy-cli](https://github.com/therealklanni/guppy-cli) commandline tool.*\n\n#### guppy.src(*hookName*)\n\n\u003e Supported hooks: `applypatch-msg`, `commit-msg`, `pre-applypatch`, `pre-commit`,\n`prepare-commit-msg`\n\nPass in the name of the desired git-hook and get back the related filenames.\nThis allows you to work with the source file directly, for example to modify a\ncommit-msg programmatically or lint changed files.\n\n*Note for pre-commit and pre-applypatch this will give you the ***working-copy***,\nnot the indexed (staged) changes. If you want the indexed changes, use\n`guppy.stream()` instead.*\n\n```js\n// contrived example\ngulp.task('pre-commit', function () {\n  return gulp.src(guppy.src('pre-commit'))\n    .pipe(gulpFilter(['*.js']))\n    .pipe(jshint())\n    .pipe(jshint.reporter(stylish))\n    .pipe(jshint.reporter('fail'));\n});\n```\n\n#### guppy.src(*hookName[, fn]*)\n\n\u003e Supported hooks: all\n\nIf you pass the optional `fn` argument, it will be passed to `gulp.task()` as the\ntask callback, but the first argument will be the related filenames (or `null`,\nif none) and a second optional argument may also be supplied (when applicable)\nwith any additional arguments received from the git-hook as an array. gulp will\nprovide its callback as the last argument.\n\n```js\n// less contrived example\ngulp.task('pre-commit', guppy.src('pre-commit', function (filesBeingCommitted) {\n  return gulp.src(filesBeingCommitted)\n    .pipe(gulpFilter(['*.js']))\n    .pipe(jshint())\n    .pipe(jshint.reporter(stylish))\n    .pipe(jshint.reporter('fail'));\n}));\n\n// another contrived example\ngulp.task('pre-push', guppy.src('pre-push', function (files, extra, cb) {\n  var branch = execSync('git rev-parse --abbrev-ref HEAD');\n\n  if (branch === 'master') {\n    cb('Don\\'t push master!')\n  } else {\n    cb();\n  }\n}));\n```\n\n#### guppy.stream(*hookName[, options]*)\n\n\u003e Supported hooks: `applypatch-msg`, `commit-msg`, `pre-applypatch`, `pre-commit`,\n`prepare-commit-msg`\n\nPass in the name of the git-hook to produce a stream of the related files.\nYou can pass options as a second argument, please refer to the [docs for gulp.src](https://github.com/gulpjs/gulp/blob/master/docs/API.md#gulpsrcglobs-options)\nfor more information on available options.\n\n*Note that depending on the git-hook, you may be acting on files that differ from\nyour working copy, such as those staged for commit (as with 'pre-commit' for\nexample), rather than the working copy. If you need to act on the working-copy\nfiles, use `guppy.src()` instead.*\n\n```js\ngulp.task('pre-commit', function () {\n  return guppy.stream('pre-commit')\n    .pipe(gulpFilter(['*.js']))\n    .pipe(jshint())\n    .pipe(jshint.reporter(stylish))\n    .pipe(jshint.reporter('fail'));\n});\n```\n\n#### Additional notes\n\nFor many git-hooks there are no files associated, so for those it makes sense\nto only add other gulp tasks as dependencies to invoke a workflow, however some\nwill still receive some arguments (passed in by `guppy.src()` when used as a\ncallback) for more advanced use cases.\n\n```js\ngulp.task('post-checkout', ['lint']);\n```\n\n## Writing guppy-hooks\n\n*stay tuned*\n\nFor details on what arguments each git-hook receives and what result a non-zero\nexit status would have, check the [git-scm docs](https://git-scm.com/docs/githooks).\n\n## Author\n\n**Kevin Lanni**\n\n+ [github/therealklanni](https://github.com/therealklanni)\n+ [twitter/therealklanni](http://twitter.com/therealklanni)\n\n## License\n\nMIT © Kevin Lanni\n![](https://ga-beacon.appspot.com/UA-62782014-1/git-guppy/1.0?pixel)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fratson%2Fgit-guppy-safe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fratson%2Fgit-guppy-safe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fratson%2Fgit-guppy-safe/lists"}