{ "info": { "author": "sodas", "author_email": "sodas@tickleapp.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: MacOS :: MacOS X", "Operating System :: POSIX :: Linux", "Operating System :: Unix", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Topic :: Software Development", "Topic :: Utilities" ], "description": "# Submarine Githooks\nGit-hooks used by [Tickle](https://tickleapp.com)\n\n\n## Install\n\nInstall the tool by ```pip3 install submarine-githooks```\n(or if you only have Python 2.7, use ```pip install submarine-githooks```)\n\n\n## Setup\n\nGo to your repo folder, then ```submarine-githooks install```.\nThe `install` command will create `.githooks` folder for you and link it to replace your `.git/hooks`\n\nYou could also prepare a setup script for your collaborators by ```submarine-githooks setup-script```\nThis command creates a `setup-githooks` for your collaborators to setup git hooks.\n\n(the `install` command links the .git/hooks and creates rooms for your git hooks.\n The script generated by `setup-script` just does the link thing, assuming rooms for git hooks already exists.)\n\n\n## Checkers\n\nSubmarine will find checkers from Python modules you put under `.githooks`.\nAll checkers should be an instance of `submarine_githooks.checker.Checker`, the easiest way to\ncreate a checker is:\n```python\nfrom submarine_githooks.checker import checker\n\n\n@checker\ndef a_simple_checker(*args):\n pass\n```\nand then saves it to `.githooks` as `some_checker.py`\n\nYou could reference the arguments which will be passed in at following section.\n\n### Checker settings\n\n#### Active hooks\n\n```python\n@checker\n@checker.active_hooks('pre-commit')\ndef a_checker(*args):\n pass\n\n\n@checker\n@checker.active_hooks('pre-commit', 'post-merge')\ndef another_checker(*args):\n pass\n\n\n@checker\n@checker.active_hooks('pre-commit')\n@checker.active_hooks('post-merge')\ndef third_checker(*args):\n pass\n\n```\n\nBy registering active hooks, the checker will then work only for that type of git hook.\n(By default, checkers works for all type of git hooks)\n\nIn the above example, the first checker works only for `pre-commit` hook,\nand the following 2 works for both `pre-commit` and `post-merge`.\n\nReference: [git hooks types](https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks).\n\n#### File pattern and extension\n\n```python\n@checker\n@checker.file_pattern(r'\\.py$')\ndef a_checker(*args):\n pass\n\n@checker\n@checker.file_extension('.json')\ndef another_checker(*args):\n pass\n```\n\nYou can also register supported file types for a checker.\n\n\n### Checker implementation\n\nOnce if a checker raises any Python exception, the git hook will exit with a non-zero return code.\nSo, for example, if you want to check all json files are correct and parsable before commit,\nyou could make a checker like:\n```python\n@checker\n@checker.active_hooks('pre-commit')\n@checker.file_extension('.json')\ndef pre_commit(git_repo, hook_name, file_path):\n json.loads(git_repo.file_content(file_path))\n\n```\n\nSo this checker is only active to files which has `.json` extension, and is only active for `pre-commit`.\nIf the content is not JSON-parsable (i.e. the `json.loads` method raises a `ValueError` exception), the `pre-commit` hook exits with a non-zero return code. And then the `git commit` is aborted.\n\nNote, you should use the `git_repo` object to fetch file content but not read directly from disk\nbecause the content you should check is the one which has been added into git index.\n\n\n### Checker function signatrues\n\n```python\nfrom submarine_githooks.checker import checker\n\n@checker\n@checker.active_hooks('pre-commit')\ndef pre_commit(git_repo, hook_name, file_path):\n \"\"\"\n :param git_repo: a GitRepo instance representing current git repo\n :type git_repo: taskr.contrib.git.GitRepo\n :param hook_name: the hook being executing\n :type hook_name: str\n :param file_path: the path to of a file to be committed\n :type file_path: str\n \"\"\"\n\n\n@checker\n@checker.active_hooks('commit-msg')\ndef commit_msg(git_repo, hook_name, commit_message_filepath):\n \"\"\"\n :param git_repo: a GitRepo instance representing current git repo\n :type git_repo: taskr.contrib.git.GitRepo\n :param hook_name: the hook being executing\n :type hook_name: str\n :param commit_message_filepath: the path to of file holding the commit message\n :type commit_message_filepath: str\n \"\"\"\n\n\n@checker\n@checker.active_hooks('post-merge')\ndef post_merge(git_repo, hook_name, file_path, source_commit, squash_merge):\n \"\"\"\n :param git_repo: a GitRepo instance representing current git repo\n :type git_repo: taskr.contrib.git.GitRepo\n :param hook_name: the hook being executing\n :type hook_name: str\n :param file_path: the path to of a file which has been merged\n :type file_path: str\n :param source_commit: the commit id of merge source\n :type source_commit: str\n :param squash_merge: a flag indicating this is a squash merge or not\n :type suqsh_merge: bool\n \"\"\"\n\n\n@checker\n@checker.active_hooks('post-checkout')\ndef post_checkout(git_repo, hook_name, file_path, source_commit_id, destination_commit_id):\n \"\"\"\n :param git_repo: a GitRepo instance representing current git repo\n :type git_repo: taskr.contrib.git.GitRepo\n :param hook_name: the hook being executing\n :type hook_name: str\n :param file_path: the path to of a file which is changed during the checkout\n :type file_path: str\n :param source_commit_id: ref of the previous HEAD\n :type source_commit_id: str\n :param destination_commit_id: ref of the new HEAD\n :type destination_commit_id: str\n \"\"\"\n\n\n@checker\n@checker.active_hooks('pre-push')\ndef pre_push(git_repo, hook_name,\n remote_name, remote_url,\n local_ref, local_commit_id,\n remote_ref, remote_commit_id,\n branch_deleted_from_local,\n new_branch_to_remote):\n \"\"\"\n :param git_repo: a GitRepo instance representing current git repo\n :type git_repo: taskr.contrib.git.GitRepo\n :param hook_name: the hook being executing\n :type hook_name: str\n :param remote_name: name of the remote to push to\n :type remote_name: str\n :param remote_url: url of the remote to push to\n :type remote_url: str\n :param local_ref: ref of local branch to be pushed\n :type local_ref: str\n :param local_commit_id: SHA of local branch to be pushed\n :type local_commit_id: str\n :param remote_ref: ref of remote branch to push to\n :type remote_ref: str\n :param remote_commit_id: SHA of remote branch to push to\n :type remote_commit_id: str\n :param branch_deleted_from_local: a flag indicating that local branch has been removed\n :type branch_deleted_from_local: bool\n :param new_branch_to_remote: a flag indicating that this is a new branch to be pushed to remote\n :type new_branch_to_remote: bool\n \"\"\"\n```\n\n_TODO: configurations_", "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/tickleapp/submarine-githooks", "keywords": null, "license": "Apache License 2.0", "maintainer": null, "maintainer_email": null, "name": "submarine-githooks", "package_url": "https://pypi.org/project/submarine-githooks/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/submarine-githooks/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/tickleapp/submarine-githooks" }, "release_url": "https://pypi.org/project/submarine-githooks/0.1.7/", "requires_dist": null, "requires_python": null, "summary": "Submarine Githooks", "version": "0.1.7" }, "last_serial": 1727813, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "939e0030f23f44c9b9c6f72ea8c55cc3", "sha256": "ed2bf9a64c4b6eeaa578f740733e16c5ad9e97f1636711ec2737fe3babb8447c" }, "downloads": -1, "filename": "submarine-githooks-0.0.1.tar.gz", "has_sig": false, "md5_digest": "939e0030f23f44c9b9c6f72ea8c55cc3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10079, "upload_time": "2015-07-14T08:02:53", "url": "https://files.pythonhosted.org/packages/e8/14/1cad73e9aa96c8b9d6eb5535d8e6a817684443ac723c16a0fba7868a9346/submarine-githooks-0.0.1.tar.gz" } ], "0.0.1.1": [ { "comment_text": "", "digests": { "md5": "c09464de408ecbd53e3001eb2de37703", "sha256": "a73487dcd237b45ae88b6eefaf25c91b3a6158ba5e1d5c4207995d8a0ce6aa97" }, "downloads": -1, "filename": "submarine-githooks-0.0.1.1.tar.gz", "has_sig": false, "md5_digest": "c09464de408ecbd53e3001eb2de37703", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10089, "upload_time": "2015-07-14T09:05:34", "url": "https://files.pythonhosted.org/packages/55/c8/627c28c364ea4538bd2b872a3c604ad56b68d3bb8d7cfcf35cc908df3c20/submarine-githooks-0.0.1.1.tar.gz" } ], "0.0.1.2": [ { "comment_text": "", "digests": { "md5": "1d3b740660c53e5b13c9695dbeeccd77", "sha256": "2e38195edc38cb30c5ce7129c56f43cf8e5c6714e0b5a951593b8cab373d63e0" }, "downloads": -1, "filename": "submarine-githooks-0.0.1.2.tar.gz", "has_sig": false, "md5_digest": "1d3b740660c53e5b13c9695dbeeccd77", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10121, "upload_time": "2015-07-14T09:13:56", "url": "https://files.pythonhosted.org/packages/9b/95/6bc4fa2b8afbb7b23204d56e3f9f4d53626a550b24862e2817841a987aef/submarine-githooks-0.0.1.2.tar.gz" } ], "0.0.1.post3": [ { "comment_text": "", "digests": { "md5": "979e6f80afad8b3087b17796b4d3b406", "sha256": "59f8fe439f9e8d35f0fe454a52455b96a0dad6213e4f8469e2a7de07350061f9" }, "downloads": -1, "filename": "submarine-githooks-0.0.1.post3.tar.gz", "has_sig": false, "md5_digest": "979e6f80afad8b3087b17796b4d3b406", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10208, "upload_time": "2015-07-14T09:24:30", "url": "https://files.pythonhosted.org/packages/3d/9d/cf2139bc0e75fe7db24d7059c3ae91370f53132bcb7364ad23768a90df3d/submarine-githooks-0.0.1.post3.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "eff1f761c01eac3daf22cf09613257a2", "sha256": "e6bfb333c302507bc2140575867fde7e3f67c7936b252da803dc714afa60e5fd" }, "downloads": -1, "filename": "submarine-githooks-0.1.0.tar.gz", "has_sig": false, "md5_digest": "eff1f761c01eac3daf22cf09613257a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10405, "upload_time": "2015-07-20T07:50:28", "url": "https://files.pythonhosted.org/packages/f4/0b/197e83d89d114cfa53a7eb2f14a983a8e5af9fde8739aa107b2472863dee/submarine-githooks-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "bb285ec10a51601fc70e78d0726d16de", "sha256": "837e8e0a81e20a903c567881575a4167cb72fbfce076b3e5693a4e771b32fceb" }, "downloads": -1, "filename": "submarine-githooks-0.1.1.tar.gz", "has_sig": false, "md5_digest": "bb285ec10a51601fc70e78d0726d16de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10432, "upload_time": "2015-07-20T08:18:12", "url": "https://files.pythonhosted.org/packages/93/b6/d4b057628adb423611dfea68f355c1671eb36cde69c703fd9fd5803b94f3/submarine-githooks-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "eff4c40f4d952e03fe8bcfb47459b637", "sha256": "aaeeea1f70b5fcc10dd96c8588926164932b59b7c6251849dfe593553e36d287" }, "downloads": -1, "filename": "submarine-githooks-0.1.2.tar.gz", "has_sig": false, "md5_digest": "eff4c40f4d952e03fe8bcfb47459b637", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10670, "upload_time": "2015-07-21T03:22:20", "url": "https://files.pythonhosted.org/packages/e0/bd/19715c6eb517867a8012505b998d3f736ebe7f8a64538e18339b42dafbd6/submarine-githooks-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "5bbdc6366b97ac9ead0bcbe3c9a3b82d", "sha256": "e02304247b063aed772a72d11328381cbf696fb0d683e75cacbe6cda6a61574e" }, "downloads": -1, "filename": "submarine-githooks-0.1.3.tar.gz", "has_sig": false, "md5_digest": "5bbdc6366b97ac9ead0bcbe3c9a3b82d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10704, "upload_time": "2015-07-22T11:06:18", "url": "https://files.pythonhosted.org/packages/10/e0/04af7b2d7642a6f8aa817718a2941db2937cd32d21552e552701775912f8/submarine-githooks-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "e8cfb1fc64147a6ae61184b2deb28f78", "sha256": "4133c5d80bb9917394d91709918cd409f5e0a6e7847868f1de902ae89373b103" }, "downloads": -1, "filename": "submarine-githooks-0.1.4.tar.gz", "has_sig": false, "md5_digest": "e8cfb1fc64147a6ae61184b2deb28f78", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10730, "upload_time": "2015-07-27T07:11:20", "url": "https://files.pythonhosted.org/packages/1d/d7/2f460818c8485669da199412564996a475188d006e8fbd5f213b23b95e44/submarine-githooks-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "c1a0cbc9afd076e6b2da15ac7adf33ce", "sha256": "627a85e829a9b4fd9741b886d5d89645a7a3b152fb1953ac8350754310f71af2" }, "downloads": -1, "filename": "submarine-githooks-0.1.5.tar.gz", "has_sig": false, "md5_digest": "c1a0cbc9afd076e6b2da15ac7adf33ce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10757, "upload_time": "2015-08-05T08:41:52", "url": "https://files.pythonhosted.org/packages/9c/e4/c6749c3ae2aa1ac1d7f5790479608db140c39ee63c3da685b7e7e5c9d8e4/submarine-githooks-0.1.5.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "259ce7bc72d93e1b2daf84d626c50300", "sha256": "2263ed1878d8cf516aef82786f7cde8e655d30dc8e7a8505b837c58f0890eab8" }, "downloads": -1, "filename": "submarine-githooks-0.1.6.tar.gz", "has_sig": false, "md5_digest": "259ce7bc72d93e1b2daf84d626c50300", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10771, "upload_time": "2015-08-07T08:36:00", "url": "https://files.pythonhosted.org/packages/6b/a0/d5dfc113a73dd291b97e4d194303c56c0761918661b881ae09b94a4f7615/submarine-githooks-0.1.6.tar.gz" } ], "0.1.7": [ { "comment_text": "", "digests": { "md5": "296f4b623f8103d14ad5727f6fe74772", "sha256": "5c1a06db40b49fc8aa61fbd33a9790aa6f04817c7d1707b10a0a0802d51530b0" }, "downloads": -1, "filename": "submarine-githooks-0.1.7.tar.gz", "has_sig": false, "md5_digest": "296f4b623f8103d14ad5727f6fe74772", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10766, "upload_time": "2015-09-18T08:23:43", "url": "https://files.pythonhosted.org/packages/f8/84/a08a82f22f23ddf1f1669b254465a6e8e988efb1d8761ad0b808c3717399/submarine-githooks-0.1.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "296f4b623f8103d14ad5727f6fe74772", "sha256": "5c1a06db40b49fc8aa61fbd33a9790aa6f04817c7d1707b10a0a0802d51530b0" }, "downloads": -1, "filename": "submarine-githooks-0.1.7.tar.gz", "has_sig": false, "md5_digest": "296f4b623f8103d14ad5727f6fe74772", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10766, "upload_time": "2015-09-18T08:23:43", "url": "https://files.pythonhosted.org/packages/f8/84/a08a82f22f23ddf1f1669b254465a6e8e988efb1d8761ad0b808c3717399/submarine-githooks-0.1.7.tar.gz" } ] }