{ "info": { "author": "Alex Couper", "author_email": "info@alexcouper.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)", "Operating System :: MacOS", "Operating System :: POSIX", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "[![Build Status](https://travis-ci.org/alexcouper/captainhook.svg?branch=master)](https://travis-ci.org/alexcouper/captainhook)\n\n\n#captainhook\n\nGit hook scripts\n\n## What is it\n\nA set of configurable git hooks and checks.\n\nUpon committing code, the pre-commit hook runs configured checks against the\nfiles to be committed and rejects the commit if any of the checks turned on fail.\n\n![Demo](http://f.cl.ly/items/3H0a1q2b090q2s2N3N2m/demo2.gif)\n\n## Installation\n\nInstall using pip::\n\n pip install captainhook\n\nYou can then install the hooks using::\n\n captainhook install\n\nfrom within any git repo, and the pre-commit hook will be installed.\n\n## Running without commiting\n\nYou can perform a run against all your code base using::\n\n captainhook run\n\n\n## Setting Up\n\nTo turn a check on or off, create a ``tox.ini`` or ``setup.cfg`` file (``tox.ini`` is used for all further examples)\nin the base directory of your project with a ``captainhook`` section.\n\neg::\n\n\n [captainhook]\n flake8=off\n pdb=off\n python3=on\n block_branch=on;master\n\n\nflake8, pdb and python3 checks default to being on.\n\nChecks can also be passed arguments from the config file. This is done with\nthe following notation::\n\n =;\n\nCurrently checks can only be passed a single argument and must do the parsing\nof that themselves.\n\nflake8 obeys the configuration as per the\n`flake8 docs `_ but any\npath-related options will need to use wildcard patterns (e.g.\n`exclude=*/migrations/*` instead of `exclude=migrations`).\n\nTo avoid being checked at all, you can commit using the ``--no-verify`` flag::\n\n git commit -a --no-verify\n\n\n## Checks\n\nCurrently supported checks are\n\n- block_branch: A branch blacklist; will reject commits if the active branch is\n in the list.\n\n- [flake8](https://pypi.python.org/pypi/flake8): \n Runs flake8_ on staged files (checks for [PEP 8](https://www.python.org/dev/peps/pep-0008/)\n compliance and syntax errors).\n\n- [pytest](http://pytest.org/latest/):\n Runs pytest_ in repository directory.\n\n- [pytest-cov](https://pypi.python.org/pypi/pytest-cov):\n Runs pytest-cov_ in repository directory.\n You can specify level of threshold in tox.ini as number from 0 to 100.\n\n- [pylint](http://www.pylint.org/):\n Runs pylint_ on staged files. You can specify level of threshold\n in tox.ini as number from 0 to 10.\n\n- pylint_docstrings: Runs pylint_ to check only docstrings on staged files.\n You can specify level of threshold in tox.ini as number from 0 to 10.\n\n- [frosted](https://pypi.python.org/pypi/frosted): \n Runs frosted_ on staged files (checks for Python syntax errors).\n\n- ``grep``: Runs a single ``grep`` command on staged files, rejecting the\n commit if the value being searched is found. Options are passed to ``grep``\n verbatim. Only one ``grep`` command may be specified.\n\n- [isort](https://pypi.python.org/pypi/isort):\n Runs isort_ on staged files (checks for clean Python imports according\n to [PEP 8](https://www.python.org/dev/peps/pep-0008/) and \n [PEP 328](https://www.python.org/dev/peps/pep-0328/)).\n\n- merge_marks: Rejects the commit if there are any unresolved merge marks in\n staged files.\n\n- pdb: Rejects the commit if there are any uncommented ``import pdb;\n pdb.set_trace()`` statements in staged files.\n\n- python3: Rejects the commit if staged files are not Python 3 compatible.\n Expects ``python3`` and ``2to3-2.7`` to be in the current shell ``PATH``.\n\n## Output\n\nYou only see output for checks that fail, otherwise silence.\n\nExample output upon a rejected commit::\n\n\n ===============================================================================\n Checking python3\n ===============================================================================\n --- captainhook/pre_commit.py (original)\n +++ captainhook/pre_commit.py (refactored)\n @@ -66,7 +66,7 @@\n \"Check there are changes to stash\"\n return bool(bash('git diff'))\n\n -print 'a'\n +print('a')\n ===============================================================================\n Checking flake8\n ===============================================================================\n pre-commit.py:19:1: F401 'importlib' imported but unused\n pre-commit.py:128:1: E302 expected 2 blank lines, found 1\n setup.py:25:80: E501 line too long (89 > 79 characters)\n ===============================================================================\n Rejecting commit\n ===============================================================================\n\n\n## Extending\n\nYou can add your own check to your git env quite easily.\n\nSimply add a module to ``.git/hooks/checkers`` with a ``run()`` method defined.\n\nThe method should return the error string on faillure, or a False like object\non success.\n\nFor example::\n\n $ cat .git/hooks/checkers/mine.py\n DEFAULT = 'on'\n def run():\n return \"NOT A CHANCE\"\n\nThis will block all commits if enabled.\n\nA checker can set the following variables:\n\nDEFAULT: used to determine the check is assumed \"on\" or \"off\". This value is\nonly used if tox.ini has not been used to override it. The default DEFAULT is\noff.\n\nCHECK_NAME: To override the display name of the module.\n\nREQUIRED_FILES: Files that, if present, should be included in the copy to the\ntemp directoy before analysis takes place.\n\n## Feedback\n\nI'm interested in hearing feedback - positive or negative - about this.\n\nPlease make yourself at home, create issues if you've got problems with existing behaviour, or suggestions for future improvements or anything else.\n\nYou can reach me on twitter @couperalex.\n\n# Contributing\n\nRunning pre-commit.py on its own will by default create copies of the files to\nbe committed which you probably don't want when testing a new check.\n\nYou can run the script against all your code base using::\n\n python captainhook/pre_commit.py --all\n\n\n## Testing\n\nThere are behavioural feature tests (based on ``behave``) found in the features\ndirectory.\n\nNew checks should be accompanied by a corresponding behavioural test example.\n\nTo run the behavioural tests:\n\n $ behave\n\nTo run all other tests:\n\n $ nosetests\n\nEnsure that you've installed test-requirements.txt.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/alexcouper/captainhook", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "captainhook", "package_url": "https://pypi.org/project/captainhook/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/captainhook/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/alexcouper/captainhook" }, "release_url": "https://pypi.org/project/captainhook/0.8.7/", "requires_dist": null, "requires_python": null, "summary": "A collection of git commit hooks", "version": "0.8.7" }, "last_serial": 2468378, "releases": { "0.3": [ { "comment_text": "", "digests": { "md5": "6bb53723807b56da1cfa79fc8c4fdd9d", "sha256": "768e515943550d2c9cfe1b7d48f739953846f76a600dbed15e4aa6af3e9006ff" }, "downloads": -1, "filename": "captainhook-0.3.tar.gz", "has_sig": false, "md5_digest": "6bb53723807b56da1cfa79fc8c4fdd9d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4095, "upload_time": "2014-05-08T00:45:35", "url": "https://files.pythonhosted.org/packages/5f/72/fa5c89aaf42df842ed8d4cbaf769f9ce4cdb2c35b54ef1cc1dfbebc7a86e/captainhook-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "9ae3b13201d8d17944bf02808f4c30f3", "sha256": "ea27ae513dbfa99a78f7047298965fc01bbca5884548fb492f063e8e4138cecf" }, "downloads": -1, "filename": "captainhook-0.4.tar.gz", "has_sig": false, "md5_digest": "9ae3b13201d8d17944bf02808f4c30f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4297, "upload_time": "2014-05-08T14:27:22", "url": "https://files.pythonhosted.org/packages/5e/c8/1880693882e5c9001543440aedbb9608640e779a0e924cd9ce239369924a/captainhook-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "ec848165d6b2dc5247531168ac767955", "sha256": "d42b869ea3ff202699c8c8568b66c2cb53f3a78db98b18fa96e58bf64d2fcbf4" }, "downloads": -1, "filename": "captainhook-0.5.tar.gz", "has_sig": false, "md5_digest": "ec848165d6b2dc5247531168ac767955", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4880, "upload_time": "2014-05-08T19:01:07", "url": "https://files.pythonhosted.org/packages/18/52/2bd8efcdc6db686a21519753f92017ba93218997e89a846820589d8ba833/captainhook-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "e10c735448a6b7cbf94ff76acaffb6f8", "sha256": "d3efba49bd949fc4246c041f50457b3cca9f7ec564597c592139a269b222670f" }, "downloads": -1, "filename": "captainhook-0.6.tar.gz", "has_sig": false, "md5_digest": "e10c735448a6b7cbf94ff76acaffb6f8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5739, "upload_time": "2014-05-11T00:32:30", "url": "https://files.pythonhosted.org/packages/8b/ad/ad6b0e26b6e8bdb1613d37bdabe8a8d87f92ea7f6f909373ccc6d8e1d7d2/captainhook-0.6.tar.gz" } ], "0.7": [ { "comment_text": "", "digests": { "md5": "04add14b9240ee078916533a89f4744e", "sha256": "58d163beaff12b762c8ee02f8de2c55501487e7b77c177d5ac912f432e471aca" }, "downloads": -1, "filename": "captainhook-0.7.tar.gz", "has_sig": false, "md5_digest": "04add14b9240ee078916533a89f4744e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5756, "upload_time": "2014-05-11T01:07:28", "url": "https://files.pythonhosted.org/packages/e9/f8/20babd9287a78d355a95c013059fccd6d55950183a199de6502fe9a5e398/captainhook-0.7.tar.gz" } ], "0.8": [ { "comment_text": "", "digests": { "md5": "d8182d4354e07a7576d746263e5cfe8d", "sha256": "58ea43958f738389885082ae478558a4d7776856c23ba9f1ca16b82a21f9099b" }, "downloads": -1, "filename": "captainhook-0.8.tar.gz", "has_sig": false, "md5_digest": "d8182d4354e07a7576d746263e5cfe8d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7126, "upload_time": "2014-05-11T17:26:07", "url": "https://files.pythonhosted.org/packages/19/3d/998640d64f6f0eafc4dde2a0c6e1b2625bf2db23342543ad617c3cd3caf0/captainhook-0.8.tar.gz" } ], "0.8.1": [ { "comment_text": "", "digests": { "md5": "2e4020553cd22de97d9118709b8c71f1", "sha256": "00fa195caaa637616d41961d3a99a8e82a0928fe1b4954dd36952cadcc774986" }, "downloads": -1, "filename": "captainhook-0.8.1.tar.gz", "has_sig": false, "md5_digest": "2e4020553cd22de97d9118709b8c71f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7676, "upload_time": "2014-05-12T21:21:29", "url": "https://files.pythonhosted.org/packages/87/9c/29d02938d9e19e3955ae41bb2cd263ed0acbae814ebbc39f41e87c72c848/captainhook-0.8.1.tar.gz" } ], "0.8.2": [ { "comment_text": "", "digests": { "md5": "341ac2cc4a8a573ad4458ace330f1bab", "sha256": "4731dc1ef8a21edd8d761d54a6bd1af24aa1826e0d216882538e544e3146f79f" }, "downloads": -1, "filename": "captainhook-0.8.2.tar.gz", "has_sig": false, "md5_digest": "341ac2cc4a8a573ad4458ace330f1bab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9784, "upload_time": "2014-05-31T14:18:44", "url": "https://files.pythonhosted.org/packages/b1/16/e500f9edbdadcc3c678c82c689e7b40f327accafd255a315153d51d52028/captainhook-0.8.2.tar.gz" } ], "0.8.3": [ { "comment_text": "", "digests": { "md5": "afefed3b192c6dc0b71f613895a89fcc", "sha256": "f10a4a01f490d18ef7b7ea744fb3510302f9477a192f66bea03922e7c167911a" }, "downloads": -1, "filename": "captainhook-0.8.3.tar.gz", "has_sig": false, "md5_digest": "afefed3b192c6dc0b71f613895a89fcc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10350, "upload_time": "2014-06-03T22:52:06", "url": "https://files.pythonhosted.org/packages/5c/a0/9c968a7dd9f17a7f75095d80a80c0684fdbf64830db272aaa8f9da19df1a/captainhook-0.8.3.tar.gz" } ], "0.8.4": [ { "comment_text": "", "digests": { "md5": "15ec7d5208fb0b8c3ec9d370e4f4e784", "sha256": "80913883535a59effd2aaecb85f4d2c259abf2d338355547505e20fe792d6a2d" }, "downloads": -1, "filename": "captainhook-0.8.4.tar.gz", "has_sig": false, "md5_digest": "15ec7d5208fb0b8c3ec9d370e4f4e784", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10824, "upload_time": "2014-06-11T22:30:39", "url": "https://files.pythonhosted.org/packages/ee/f5/0adde32f62377bb02a7dec4a4ccf2ada6d1c384991fe1768f992223ef728/captainhook-0.8.4.tar.gz" } ], "0.8.5": [ { "comment_text": "", "digests": { "md5": "270e4339b45e3b758066550ec68f13f2", "sha256": "a84f2e9259ef3b1320d89e5f553c9364fa5e7f20d3c6624e87dcae0142a4a5bd" }, "downloads": -1, "filename": "captainhook-0.8.5.tar.gz", "has_sig": false, "md5_digest": "270e4339b45e3b758066550ec68f13f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11715, "upload_time": "2014-07-18T23:21:14", "url": "https://files.pythonhosted.org/packages/02/2c/9c374e0d3090bf92fb86e0c3ce0e5ae111ed819a00ab06c11dc7eecefdba/captainhook-0.8.5.tar.gz" } ], "0.8.6": [ { "comment_text": "", "digests": { "md5": "6a8b1e78cec472c4998270602aa2f5e1", "sha256": "90f896b6f7e6e08fcf419f24f48738f4eab630b8f054ec7ed96f6ff7ea0f3b3a" }, "downloads": -1, "filename": "captainhook-0.8.6.tar.gz", "has_sig": false, "md5_digest": "6a8b1e78cec472c4998270602aa2f5e1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13590, "upload_time": "2015-10-02T20:33:16", "url": "https://files.pythonhosted.org/packages/4c/c7/ef4d3862ccd4547fa5ceec0d6696d40338377adb41602575f20f97988511/captainhook-0.8.6.tar.gz" } ], "0.8.7": [ { "comment_text": "", "digests": { "md5": "808a944c76ef1486404d317930a772db", "sha256": "29b3041ed44c554190e63150c5c5e46f83fb5858a0069996065ca130c6784562" }, "downloads": -1, "filename": "captainhook-0.8.7.tar.gz", "has_sig": false, "md5_digest": "808a944c76ef1486404d317930a772db", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13729, "upload_time": "2016-11-18T12:37:57", "url": "https://files.pythonhosted.org/packages/1f/7f/daf73cbcaa3907fd95c8175b67d76edbf43ddf806ff6191034b741fc25db/captainhook-0.8.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "808a944c76ef1486404d317930a772db", "sha256": "29b3041ed44c554190e63150c5c5e46f83fb5858a0069996065ca130c6784562" }, "downloads": -1, "filename": "captainhook-0.8.7.tar.gz", "has_sig": false, "md5_digest": "808a944c76ef1486404d317930a772db", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13729, "upload_time": "2016-11-18T12:37:57", "url": "https://files.pythonhosted.org/packages/1f/7f/daf73cbcaa3907fd95c8175b67d76edbf43ddf806ff6191034b741fc25db/captainhook-0.8.7.tar.gz" } ] }