Git API Classes — github3.py 4.0.1 documentation (original) (raw)
This part of the documentation covers the module associated with theGit Data section of the GitHub API.
Like much of the GitHub API, many objects have different representations.
Blob Object(s)
class github3.git.Blob(json, session: GitHubSession)
This object provides an interface to the API representation of a blob.
See also: http://developer.github.com/v3/git/blobs/
Changed in version 1.0.0:
- The content is no longer forcibly coerced to bytes.
This object has the following atributes
content
The raw content of the blob. This may be base64 encoded text. Usedecode_content()
to receive the non-encoded text.
encoding
The encoding that GitHub reports for this blob’s content.
size
The size of this blob’s content in bytes.
sha
The SHA1 of this blob’s content.
Commit Object(s)
class github3.git.Commit(json, session: GitHubSession)
This represents a commit as returned by the git API.
This is distinct from RepoCommit. Primarily this object represents the commit data stored by git and it has no relationship to the repository on GitHub.
See also: http://developer.github.com/v3/git/commits/
This object has all of the attributes of aShortCommit as well as the following attributes:
parents
The list of commits that are the parents of this commit. This may be empty if this is the initial commit, or it may have several if it is the result of an octopus merge. Each parent is represented as a dictionary with the API URL and SHA1.
sha
The unique SHA1 which identifies this commit.
verification
The GPG verification data about this commit. Seehttps://developer.github.com/v3/git/commits/#commit-signature-verificationfor more information.
class github3.git.ShortCommit(json, session: GitHubSession)
This represents a commit as returned by the git API.
This is distinct from RepoCommit. Primarily this object represents the commit data stored by git. This shorter representation of a Commit is most often found on aRepoCommit to represent the git data associated with it.
See also: http://developer.github.com/v3/git/commits/
This object has the following attributes:
This is a dictionary with at least the name and email of the author of this commit as well as the date it was authored.
committer
This is a dictionary with at least the name and email of the committer of this commit as well as the date it was committed.
message
The commit message that describes the changes as written by the author and committer.
tree
The git tree object this commit points to.
Tree Object(s)
class github3.git.CommitTree(json, session: GitHubSession)
This object represents the abbreviated tree data in a commit.
The API returns different representations of different objects. When representing a ShortCommit orCommit, the API returns an abbreviated representation of a git tree.
This object has the following attributes:
sha
The SHA1 of this tree in the git repository.
class github3.git.Hash(json, session: GitHubSession)
This is used to represent the elements of a tree.
This provides the path to the object and the type of object it is. For a brief explanation of what these types are and represent, this StackOverflow question answers some of that:https://stackoverflow.com/a/18605496/1953283
See also: http://developer.github.com/v3/git/trees/#create-a-tree
This object has the following attributes:
mode
The mode of the file, directory, or link.
path
The path to the file, directory, or link.
sha
The SHA1 for this hash.
size
This attribute is only not None
if the type is not a tree.
type
The type of git object this is representing, e.g., tree, blob, etc.
class github3.git.Tree(json, session: GitHubSession)
This represents a tree object from a git repository.
Trees tend to represent directories and subdirectories.
See also: http://developer.github.com/v3/git/trees/
This object has the following attributes:
sha
The SHA1 of this tree in the git repository.
tree
A list that represents the nodes in the tree. If this list has members it will have instances of Hash.
Git Object, Reference, and Tag Object(s)
Yes, we know, GitObject
is a funky name.
class github3.git.GitObject(json, session: GitHubSession)
This object represents an arbitrary ‘object’ in git.
This object is intended to be versatile and is usually found on one of the following:
This object has the following attributes:
sha
The SHA1 of the object this is representing.
type
The name of the type of object this is representing.
class github3.git.Reference(json, session: GitHubSession)
Object representing a git reference associated with a repository.
This represents a reference (or ref) created on a repository via git.
See also: http://developer.github.com/v3/git/refs/
This object has the following attributes:
object
A GitObject that this reference points to.
ref
The string path to the reference, e.g., 'refs/heads/sc/feature-a'
.
class github3.git.Tag(json, session: GitHubSession)
This represents an annotated tag.
Tags are a special kind of git reference and annotated tags have more information than lightweight tags.
See also: http://developer.github.com/v3/git/tags/
This object has the following attributes:
message
This is the message that was written to accompany the creation of the annotated tag.
object
A GitObject that represents the underlying git object.
sha
The SHA1 of this tag in the git repository.
tag
The “lightweight” tag (or reference) that backs this annotated tag.
tagger
The person who created this tag.