Skip to main content

Intuitive Git for Python

Project description

ci python3.8 pypi codecov.io mit black

Intuitive Git for Python

Install

Dependencies: git ^2.0.0 (tested)

pip install gitspy

Development

poetry install

Example Usage

Get branch

>>> import gitspy
>>> git = gitspy.Git()
>>> # capture will store stdout, which can then be consumed by
>>> # calling `git.stdout()`
>>> # default is to print stdout, and stderr, to console
>>> returncode = git.symbolic_ref("--short", "HEAD", capture=True)
>>> print(returncode)  # printing returncode
0
>>> # consume stdout, a list containing a `str` of the checked out
>>> # branch
>>> stdout = git.stdout()  # -> ['checked-out-branch']
>>> items = len(stdout)  # printing length of `stdout()` outputs
>>> print(items)
1
>>> # no commands have been called yet since last call to `stdout`,
>>> # so stdout is empty
>>> stdout = git.stdout()  # -> []
>>> items = len(stdout)  # printing length of ``stdout()`` outputs
>>> print(items)
0
>>> # stdout can be accrued
>>> # ['checked-out-branch', 'checked-out-branch']
>>> git.symbolic_ref("--short", "HEAD", capture=True)
>>> git.symbolic_ref("--short", "HEAD", capture=True)
>>> print(len(git.stdout()))
2
>>> # stdout is consumed
>>> print(len(git.stdout()))
0
>>> git.symbolic_ref("--short", "HEAD", capture=True)
>>> git.stdout()  # [...] -> void; clear stdout, if it exists
>>> print(len(git.stdout()))
0

Get commit hash

>>> import gitspy
>>> git = gitspy.Git()
>>> git.rev_parse("HEAD", capture=True)
>>> stored = git.stdout()[0]
>>> print(len(stored))  # print the length of the unique hash
40

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitspy-0.1.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

gitspy-0.1.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file gitspy-0.1.1.tar.gz.

File metadata

  • Download URL: gitspy-0.1.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.8.11+ Linux/5.15.11-200.fc35.x86_64

File hashes

Hashes for gitspy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b91fdb56ee9e0ca16a0243f38cb99fc40473562680f91e7a2be1aac736f89fae
MD5 69ecabba9c9affb14223b9cb0a255fc0
BLAKE2b-256 801425d0e4ece169c2afa5009c35e03a21f033d2f1688a7535e9a2f1fe45501e

See more details on using hashes here.

File details

Details for the file gitspy-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: gitspy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.8.11+ Linux/5.15.11-200.fc35.x86_64

File hashes

Hashes for gitspy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f506b18667a1655b03978bf354301d918a0d91a6d021e2c0f367b3d31944199
MD5 82438cbaf3f288579e9b024f6c5c663a
BLAKE2b-256 d092dbcbf42c1d3a118bd0360c4bda76d48fb3bea460b37ce45e8183001706ae

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page