Git API Classes

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)

classgithub3.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:

  • Thecontent 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)

classgithub3.git.Commit(json,session:GitHubSession)

This represents a commit as returned by the git API.

This is distinct fromRepoCommit.Primarily this object represents the commit data stored by git andit 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 beempty if this is the initial commit, or it may have several if it isthe result of an octopus merge. Each parent is represented as adictionary 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.

classgithub3.git.ShortCommit(json,session:GitHubSession)

This represents a commit as returned by the git API.

This is distinct fromRepoCommit.Primarily this object represents the commit data stored by git. Thisshorter representation of a Commit is most often found on aRepoCommit to represent the git dataassociated with it.

See also:http://developer.github.com/v3/git/commits/

This object has the following attributes:

author

This is a dictionary with at least the name and email of the authorof this commit as well as the date it was authored.

committer

This is a dictionary with at least the name and email of the committerof this commit as well as the date it was committed.

message

The commit message that describes the changes as written by the authorand committer.

tree

The git tree object this commit points to.

Tree Object(s)

classgithub3.git.CommitTree(json,session:GitHubSession)

This object represents the abbreviated tree data in a commit.

The API returns different representations of different objects. Whenrepresenting aShortCommit orCommit, the API returns an abbreviatedrepresentation of a git tree.

This object has the following attributes:

sha

The SHA1 of this tree in the git repository.

classgithub3.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. Fora brief explanation of what these types are and represent, thisStackOverflow 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 notNone if thetype is not a tree.

type

The type of git object this is representing, e.g., tree, blob, etc.

classgithub3.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 membersit will have instances ofHash.

Git Object, Reference, and Tag Object(s)

Yes, we know,GitObject is a funky name.

classgithub3.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 thefollowing:

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.

classgithub3.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

AGitObject that this reference points to.

ref

The string path to the reference, e.g.,'refs/heads/sc/feature-a'.

classgithub3.git.Tag(json,session:GitHubSession)

This represents an annotated tag.

Tags are a special kind of git reference and annotated tags have moreinformation 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 theannotated tag.

object

AGitObject that represents the underlying gitobject.

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.