Skip to main content

Convenience library for working with Git on Linux. Requires git >= 2.20

Project description

Python GIT Library

  • License: 3-Clause BSD
  • Pythons: Python 3.5+
  • Platforms: Linux
  • Git: 2.20+

This library is Just What You Need when working with git repositories from Python. It is simple, but extremely flexible.

Provides Commit objects and easy branch inspection.

Git.run() method returns subprocess.run() results, but takes git command as string argument.

Table of Contents

Installation

Append downloaded repository path to PYTHONPATH.

Quickstart

Import Git class:

from atudomain.git.Git import Git

Create Git object:

git = Git('/home/user/example-repo')

Getting branches

Get list of remote origin branches:

branches = git.get_branches(include='^remotes/origin')

Get list of local branches:

branches = git.get_branches(exclude='^remotes/')

Getting Commits

Get list of Commits for the current branch:

commits = git.get_commits()

Get list with last Commit for the current branch:

commits = git.get_commits('HEAD^..HEAD')

Getting Commit details

Get committer date from Commit:

committer_date = commits[0].committer_date

Get commit id from Commit:

commit_id = commits[0].commit_id

Check if Commit is a merge:

is_merge = commits[0].is_merge

Executing commands in repository

Get 'git status -s' output as a string:

result = git.run('status -s').stdout

API Documentation

https://atudomain-python-git.readthedocs.io/en/latest/

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

atudomain-git-1.1.0.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distribution

atudomain_git-1.1.0-py3-none-any.whl (9.1 kB view hashes)

Uploaded Python 3

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