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_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.
A dict of tags in the repo
-
-
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]
-
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.
- commit (
-
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.
-
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.
-
The author of the commit.
timedate
When the commit was created.
-
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.
-
tag
¶ str
The name of 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).
-