Git

This part of the documentation covers the module associated with the Git Data section of the GitHub API.

Git Objects

class github3.git.Blob(blob)

The Blob object.

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

content = None

Raw content of the blob.

decoded = None

Decoded content of the blob.

encoding = None

Encoding of the raw content.

from_json(json)

Return an instance of cls formed from json.

sha = None

SHA1 of the blob

size = None

Size of the blob in bytes

to_json()

Return the json representing this object.


class github3.git.Commit(commit, session=None)

The Commit object. This represents a commit made in a repository.

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

author = None

dict containing at least the name, email and date the commit was created

author_as_User()

Attempt to return the author attribute as a User. No guarantees are made about the validity of this object, i.e., having a login or created_at object.

committer = None

dict containing similar information to the author attribute

committer_as_User()

Attempt to return the committer attribute as a User object. No guarantees are made about the validity of this object.

from_json(json)

Return an instance of cls formed from json.

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

Parameters:conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional Requests section of the docs
Returns:self

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('kennethreitz')]

Without the return value, that would be an array of None‘s and you would otherwise have to do:

repos = [r for i in g.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

to_json()

Return the json representing this object.

tree = None

Tree the commit belongs to.


class github3.git.GitData(data, session=None)

The GitData object. This isn’t directly returned to the user (developer) ever. This is used to prevent duplication of some common items among other Git Data objects.

from_json(json)

Return an instance of cls formed from json.

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

Parameters:conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional Requests section of the docs
Returns:self

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('kennethreitz')]

Without the return value, that would be an array of None‘s and you would otherwise have to do:

repos = [r for i in g.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

sha = None

SHA of the object

to_json()

Return the json representing this object.


class github3.git.GitObject(obj)

The GitObject object.

from_json(json)

Return an instance of cls formed from json.

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

Parameters:conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional Requests section of the docs
Returns:self

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('kennethreitz')]

Without the return value, that would be an array of None‘s and you would otherwise have to do:

repos = [r for i in g.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

to_json()

Return the json representing this object.

type = None

The type of object.


class github3.git.Hash(info)

The Hash object.

See also: http://developer.github.com/v3/git/trees/#create-a-tree

from_json(json)

Return an instance of cls formed from json.

mode = None

File mode

path = None

Path to file

sha = None

SHA of the hash

size = None

Size of hash

to_json()

Return the json representing this object.

type = None

Type of hash, e.g., blob

url = None

URL of this object in the GitHub API


class github3.git.Reference(ref, session=None)

The Reference object. This represents a reference created on a repository.

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

delete()

Delete this reference.

Returns:bool
from_json(json)

Return an instance of cls formed from json.

object = None

GitObject the reference points to

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
ref = None

The reference path, e.g., refs/heads/sc/featureA

refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

Parameters:conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional Requests section of the docs
Returns:self

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('kennethreitz')]

Without the return value, that would be an array of None‘s and you would otherwise have to do:

repos = [r for i in g.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

to_json()

Return the json representing this object.

update(sha, force=False)

Update this reference.

Parameters:
  • sha (str) – (required), sha of the reference
  • force (bool) – (optional), force the update or not
Returns:

bool


class github3.git.Tag(tag)

The Tag object.

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

from_json(json)

Return an instance of cls formed from json.

message = None

Commit message for the tag

object = None

GitObject for the tag

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

Parameters:conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional Requests section of the docs
Returns:self

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('kennethreitz')]

Without the return value, that would be an array of None‘s and you would otherwise have to do:

repos = [r for i in g.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

tag = None

String of the tag

tagger = None

dict containing the name and email of the person

to_json()

Return the json representing this object.


class github3.git.Tree(tree, session=None)

The Tree object.

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

from_json(json)

Return an instance of cls formed from json.

ratelimit_remaining

Number of requests before GitHub imposes a ratelimit.

Returns:int
recurse()

Recurse into the tree.

Returns:Tree
refresh(conditional=False)

Re-retrieve the information for this object and returns the refreshed instance.

Parameters:conditional (bool) – If True, then we will search for a stored header (‘Last-Modified’, or ‘ETag’) on the object and send that as described in the Conditional Requests section of the docs
Returns:self

The reasoning for the return value is the following example:

repos = [r.refresh() for r in g.iter_repos('kennethreitz')]

Without the return value, that would be an array of None‘s and you would otherwise have to do:

repos = [r for i in g.iter_repos('kennethreitz')]
[r.refresh() for r in repos]

Which is really an anti-pattern.

Changed in version 0.5.

to_json()

Return the json representing this object.

tree = None

list of Hash objects