{ "info": { "author": "Serafeim Papastefanos", "author_email": "spapas@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Version Control :: Git" ], "description": "# python-git-info\n\nA very simple project to get information from the git repository of your project.\nThis package does not have any dependencies; it reads directly the data from the\n.git repository.\n\n## Installation\n\nJust do a `pip install gitinfo`, or copy the `gitinfo/gitinfo.py` file to your\nproject directly. This project should work with both python 2.7 and 3.x.\n\n## Usage\n\nThis app will search the current directory for a `.git` directory (which is\nalways contained inside the root directory of a project). If one is found\nit will be used; else it will search the parent directory recursively until a\n`.git` is found.\n\nThere's a single function name `get_git_info()` with an optional `dir` parameter.\nIf you leave it empty it will start the `.git` directory search from the current directory,\nif you provide a value for `dir` it will start from that directory. The `get_git_info`\nwill return a dictionary with the following structure if everything works ok or\n`None` if something fishy happend or no `.git` folder was found:\n\n```\n {\n 'parent_commit': 'd54743b6e7cf9dc36354fe2907f2f415b9988198', \n 'message': 'commit: Small restructuring\\n', \n 'commiter': 'Serafeim ', \n 'commit_date': '2018-11-14 13:52:34', \n 'author': 'Serafeim ', \n 'author_date': '2018-11-14 13:52:34', \n 'commit': '9e1eec364ad24df153ca36d1da8405bb6379e03b'\n }\n```\n\n## How it works\n\nThis project will return the info from the latest commit of your *current* branch. To do this, it will read the `.git/HEAD` file which contains your current branch (i.e something like `ref: refs/heads/master`). It will then read the file it found there (i.e `.git/refs/heads/master`) to retrieve the actual sha of the latest commit, something like `8f6223c849d4bba75f037aeeb8660d9e6e306862`. \n\nThis object is located in`.git/objects/8f/6223c849d4bba75f037aeeb8660d9e6e306862` (notice\nthe first two characters are a directory name and the rest is the actual filename). This\nis a zlib compressed folder. After it is uncompressed it has a simple format; I'm\ncopying from the git internals manual:\n\n> The format for a commit object is simple: it specifies the top-level tree for the snapshot of the project at that point; the parent commits if any (the commit object described above does not have any parents); the author/committer information (which uses your user.name and user.email configuration settings and a timestamp); a blank line, and then the commit message.\n\nSo a sample commit message file would be something like this:\n\n```\ntree fa077d18fe3309aa12791dad2f733bfbb50fdee6\nparent 943f6e8e3641ea38a9d9db3256944b46bcfc1f77\nauthor Serafeim Papastefanos 1562836041 +0300\ncommitter Serafeim Papastefanos 1562836041 +0300\n\nprep new ver\n```\n\n## The \"pack\" of snakes\n\nUntil now everything seems like sunshine; unfortunately there's a can of snakes in this process or better a `pack` of snakes: Non trivial git repositories will\ncompress the contents of their `.git/objects` folder to save network (and disk) space to a file ending with `.pack`. This file is a dump of all the (zlib compressed)\nobject your repository contains (including the commit messages of course) and is accompanied by a `.idx` object which says where each object can be found in the \npack file. You can find these files in `.git/objects/pack` folder (if your repository has them of course). \n\nIn any case, the process of reading the `.idx` file to find the index of your commit and then reading that from the `.pack` file is not trivial; if you want\nto learn more about it you can check out this excellent resource: https://codewords.recurse.com/issues/three/unpacking-git-packfiles\n\nOr you can take a look at my code at the `pack_reader` module which I tried to heavily commit to improve understanding.\n\n## Rationale\n\nThis project may seem useless or very useful, depending on the way you deploy to your servers. If you, like me, push every changeset to your VCS *before* deploying and then pull the changes from the remote server to actually deploy then you'll find this project priceless: You can easily add the latest commit information to somewhere in your web application so you'll be able to see immediately which changeset is deployed to each server without the need to actually login to the server and do a `git log`.\n\nAlso it is important to add here that this project is pure python and does not have\nany external dependencies (not even `git`); making it very easy to install and \nuse in any project.\n\n## Changes\n\n0.6.1\n\n* Remove non-needed print stmts\n\n0.6\n\n* It now parses the pack file to retrieve the commit object if it is packed!\n\n0.5\n\n* Change the parsing algorithm from using `.git/logs` to parse the real commit object inside the `.git/objects` folder.\n\n\n0.4\n\n* Add more error checks\n\n0.3\n\n* Make it work with '..'\n\n0.2\n\n* Initial", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/spapas/python-git-info/", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "python-git-info", "package_url": "https://pypi.org/project/python-git-info/", "platform": "", "project_url": "https://pypi.org/project/python-git-info/", "project_urls": { "Homepage": "https://github.com/spapas/python-git-info/" }, "release_url": "https://pypi.org/project/python-git-info/0.6.1/", "requires_dist": null, "requires_python": "", "summary": "Get git information repository, directly from .git", "version": "0.6.1" }, "last_serial": 5576116, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "3e01cd4530d80087cc7bed44ac02451d", "sha256": "1f1aaeb95a766359fb493a64f59c7266bda6bd8f5c701ce5069b1d0c8d4fca07" }, "downloads": -1, "filename": "python-git-info-0.1.0.tar.gz", "has_sig": false, "md5_digest": "3e01cd4530d80087cc7bed44ac02451d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1743, "upload_time": "2018-11-14T12:34:34", "url": "https://files.pythonhosted.org/packages/29/3a/8b78cdf77d400334512bfc7196551d19be65fa9c93462fb218adc66c7871/python-git-info-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "fb80ee701824eeb4407818393a5bc908", "sha256": "eaa305a3fb51fb10682236cb2b59b4055b04d45e4d381dce60092e4bc87d6ffd" }, "downloads": -1, "filename": "python-git-info-0.2.0.tar.gz", "has_sig": false, "md5_digest": "fb80ee701824eeb4407818393a5bc908", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2640, "upload_time": "2018-11-14T12:40:52", "url": "https://files.pythonhosted.org/packages/e9/31/f4e8502dd27e814276a89000761cd00f02724a74d1fc523c9c8d8b74d6b0/python-git-info-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "57d7f28d3c1cc29b9356b5afbc404775", "sha256": "da44d3ed90aa003248db406e4d6c2f25643024f670ae4283eead7db80b9ef379" }, "downloads": -1, "filename": "python-git-info-0.3.0.tar.gz", "has_sig": false, "md5_digest": "57d7f28d3c1cc29b9356b5afbc404775", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2724, "upload_time": "2018-11-15T07:23:45", "url": "https://files.pythonhosted.org/packages/d4/f7/29ec8127b27afd4bb6257e0d01f5e94cbf5c150def28395a6e1b3ef857ba/python-git-info-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "b0698532d6b3b1969980b91db30981ff", "sha256": "8f102b77dc4300943bdb2acdec58699800e308096175a6c3456c3168923f1043" }, "downloads": -1, "filename": "python-git-info-0.4.0.tar.gz", "has_sig": false, "md5_digest": "b0698532d6b3b1969980b91db30981ff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3469, "upload_time": "2019-07-11T09:10:08", "url": "https://files.pythonhosted.org/packages/4b/5a/115a7e6e9f597bb11c6e8682e80f5d2be1fabb5692352a8acffd81b1ca7c/python-git-info-0.4.0.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "a7af5c3a2432027557c341d24cff1bc5", "sha256": "9798033bc1dc698b982f682273e10c7c04934eef8482b21a92e3556ab85eb510" }, "downloads": -1, "filename": "python-git-info-0.5.0.tar.gz", "has_sig": false, "md5_digest": "a7af5c3a2432027557c341d24cff1bc5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4371, "upload_time": "2019-07-23T08:01:19", "url": "https://files.pythonhosted.org/packages/8c/ae/d545128357cfb2f7ed8f612b32a6999d85b5e489e44981cf00fdaea95b5d/python-git-info-0.5.0.tar.gz" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "a4c15db541584ee4250855d7f62abf1d", "sha256": "664ffd894baa68eec6b976cf2d71dbac1807b7459f7848b6e5b1d4c181917bfe" }, "downloads": -1, "filename": "python-git-info-0.6.0.tar.gz", "has_sig": false, "md5_digest": "a4c15db541584ee4250855d7f62abf1d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6426, "upload_time": "2019-07-24T06:37:12", "url": "https://files.pythonhosted.org/packages/15/06/cb53e041ec3af3715c185abeabec7cf22f22629cbe45c21a3bc661620205/python-git-info-0.6.0.tar.gz" } ], "0.6.1": [ { "comment_text": "", "digests": { "md5": "179a5375212b253fd1d40a938d077123", "sha256": "75ba1016873b014e17263ba512b9bd0304de2a55f1724858bd48cce932f49702" }, "downloads": -1, "filename": "python-git-info-0.6.1.tar.gz", "has_sig": false, "md5_digest": "179a5375212b253fd1d40a938d077123", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6433, "upload_time": "2019-07-24T06:42:47", "url": "https://files.pythonhosted.org/packages/57/29/7b07a861360160525f2968f8798524b96117b9dc49b2828c5293557aaea9/python-git-info-0.6.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "179a5375212b253fd1d40a938d077123", "sha256": "75ba1016873b014e17263ba512b9bd0304de2a55f1724858bd48cce932f49702" }, "downloads": -1, "filename": "python-git-info-0.6.1.tar.gz", "has_sig": false, "md5_digest": "179a5375212b253fd1d40a938d077123", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6433, "upload_time": "2019-07-24T06:42:47", "url": "https://files.pythonhosted.org/packages/57/29/7b07a861360160525f2968f8798524b96117b9dc49b2828c5293557aaea9/python-git-info-0.6.1.tar.gz" } ] }