Commit

Note

See the official GitHub API v2 documentation for commits.

class github2.commits.Commit(type)[source]

Commit container.

modified

(If present) Datastructure representing what’s been modified since last commit.

message

Commit message.

author

Author metadata (dict with name/email.)

authored_date

Date authored.

committer

Comitter metadata (dict with name/email.)

tree

Tree SHA for this commit.

id

Commit ID.

removed

(if present) Datastructure representing what’s been removed since last commit.

url

Canonical URL for this commit.

committed_date

Date committed.

parents

List of parents for this commit.

added

(If present) Datastructure representing what’s been added since last commit.

class github2.commits.Commits(type)[source]

GitHub API commits functionality.

list(project, branch='master', file=None, page=1)[source]

List commits on a project.

Warning

Not all projects use master as their default branch, you can check the value of the Repo(project).master_branch attribute to determine the default branch of a given repository.

Parameters:
  • project (str) – project name
  • branch (str) – branch name, or master if not given
  • file (str) – optional file filter
  • page (int) – optional page number
show(project, sha)[source]

Get a specific commit.

Parameters:
  • project (str) – project name
  • sha (str) – commit id

Examples

Listing Commits on a Branch

>>> commits = github.commits.list("mojombo/grit", "master")

By default the first page of results is returned, you can return further results with the page parameter:

>>> commits = github.commits.list("mojombo/grit", "master", page=2)

Listing Commits for a File

>>> commits = github.commits.list("mojombo/grit", "master",
...                               file="grit.gemspec")

Showing a Specific Commit

>>> commit = github.commits.show("mojombo/grit",
...             sha="5071bf9fbfb81778c456d62e111440fdc776f76c")

Table Of Contents

Previous topic

Repository

Next topic

Object

This Page