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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for atudomain_git-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a148f8a586241f2627cc4b27db72ef5983c66b411064e431f40b90534bb5e3c |
|
MD5 | 4cac9ac7b360f3d8052a6224a26d6578 |
|
BLAKE2b-256 | 7ea61b62548d3e309def104a713d034462d7b25a9b8c5c0dbc4f0e9520a37a3b |