maggit package api

class maggit.Sha[source]

Bases: bytes

A Sha is a git sha. It means that it is the identifier of a git object.

Sha are store in Maggit as a 20 bytes len.

hexbytes

The sha as a hexlified bytes

hexstr

The sha as a hexlified str

class maggit.Repo(gitdir=None, disable_directoryLooking=False, bare=False)[source]

Bases: maggit.db.repo.Repo

This is the central piece of a git repository.

HEAD

The current checkouted branch

branches

A dict of branches in the repo

get_full_sha(prefix)[source]

Return the full Sha of the prefix

Parameters:prefix (bytes) – The beginning of a sha.
Returns:class:~maggit.Sha corresponding.
Return type:The
Exemples:
>>> repo.get_full_sha(b'bf09f0a9')
<Sha b'bf09f0a9...'>
Raises::Exception – If number of object corresponding to prefix is not equal to one.
get_git_dir(dirToCheck=None)[source]
get_object(sha)[source]

Get a git object for the sha.

Parameters:sha (Sha) – The sha of the object.
Returns:class:~maggit.gitObjects.GitObject object for this sha.
Return type:A
Raises::Exception – If sha doesn’t name a object.
init_repo(gitdir, bare=False)[source]

Instantiate a new git repo at the given location.

tags

A dict of tags in the repo

class maggit.Person(name, email)[source]
class maggit.Entry(commit, path)[source]

A Entry represent a entry (file or directory) at a specific time.

We can somehow see a repository as a complex 2 dimentionnal array. Commits (and so the history) are rows. Files (and Trees) are columns.

In this situations, Entry are the cells of this array.

Parameters:
  • commit (maggit.Commit) – The commit associated to the Entry
  • path (bytes path) – The path of the file to look at. The path must be a bytes where directory are separated by b’/’.
Raise:
KeyError if the path is not existing.
get_first_appearance()[source]

Return the commit who firstly introduce the current version of the change.

Returns:class:maggit.Commit
Return type:A
Exemples:
>>> first_appearance_commit = this_entry.get_first_appearance()
>>> # first_appearance_commit is the first one, so previous version differs
>>> parent = first_appearance_commit.parents[0]
>>> assert Entry(first_appearance_commit, this_entry.path).gitObject != Entry(parent, this_entry.path).gitObject
>>> # from this_commit to first_appearance_commit, there is no change
>>> current = this_entry.commit
>>> while current != first_appearance_commit:
...     assert Entry(current, this_entry.path).gitObject == this_entry.gitObject
...     current = current.parents[0]
is_blob()[source]

Return True if the entry is corresponding to a blob object

parents

The previous versions of the files.

Previous versions can be equal to the current one if the current commit introduce no change on this file.

The length of the parents will most of the time be 1 but may be greater in case of merge.

class maggit.Blob(repo, sha)[source]

Bases: maggit.gitObjects.gitObject.GitObject

A blob object.

content

bytes

This is the content of the blob.

class maggit.Tree(repo, sha)[source]

Bases: maggit.gitObjects.gitObject.GitObject

A blob object.

entries

unmutable mapping

This is the entries of the tree.

class maggit.Commit(repo, sha)[source]

Bases: maggit.gitObjects.gitObject.GitObject

A commit object.

tree

Tree

The tree object associated with the commit.

parents

tuple

The parents of the commits. Most of the time, there will only one parent. In case of branch merge, there will be more than one parent.

author

Person

The author of the commit.

author_date

timedate

When the commit was created.

committer

Person

The committer of the commit.

committer_date

timedate

When the commit was committed.

first_line

str

The first line of the commit message.

message

str

The full commit message (including the first line).

class maggit.Tag(repo, sha)[source]

Bases: maggit.gitObjects.gitObject.GitObject

A tag object.

object

GitObject

The git object tagged by this tag.

tag

str

The name of the tag.

tagger

Person

The person who create the tag.

tagger_date

timedate

When the tag was created.

first_line

str

The first line of the tag message.

message

str

The full tag message (including the first line).

maggit.gitObjects module

class maggit.gitObjects.GitObject(repo, sha)[source]

The base class for all git objects.

Git objects are conceptualy constant. However as we try to be lazy, slots are not fill at object creation and set when user read it. So GitObject are not constant but behave as if they were.

repo

Repo

The repo associated with the object.

sha

Sha

The sha of the object.

maggit.refs module

class maggit.refs.Ref(repo, sha)[source]

Bases: maggit.refs.BaseRef

commit
repo
sha
class maggit.refs.Branche(repo, branchName)[source]

Bases: maggit.refs.BaseRef

commit
name
repo
sha
class maggit.refs.Tag(repo, tagName)[source]

Bases: maggit.refs.BaseRef

commit
name
object
repo
sha