Repository

class github.Repository.Repository

This class represents Repositories. The reference can be found here http://developer.github.com/v3/repos/

allow_merge_commit
Type:bool
allow_rebase_merge
Type:bool
allow_squash_merge
Type:bool
archived
Type:bool
archive_url
Type:string
assignees_url
Type:string
blobs_url
Type:string
branches_url
Type:string
clone_url
Type:string
collaborators_url
Type:string
comments_url
Type:string
commits_url
Type:string
compare_url
Type:string
contents_url
Type:string
contributors_url
Type:string
created_at
Type:datetime.datetime
default_branch
Type:string
description
Type:string
downloads_url
Type:string
events_url
Type:string
fork
Type:bool
forks
Type:integer
forks_count
Type:integer
forks_url
Type:string
full_name
Type:string
git_commits_url
Type:string
git_refs_url
Type:string
git_tags_url
Type:string
git_url
Type:string
has_downloads
Type:bool
has_issues
Type:bool
has_projects
Type:bool
has_wiki
Type:bool
homepage
Type:string
hooks_url
Type:string
html_url
Type:string
id
Type:integer
issue_comment_url
Type:string
issue_events_url
Type:string
issues_url
Type:string
keys_url
Type:string
labels_url
Type:string
language
Type:string
languages_url
Type:string
master_branch
Type:string
merges_url
Type:string
milestones_url
Type:string
mirror_url
Type:string
name
Type:string
network_count
Type:integer
notifications_url
Type:string
open_issues
Type:integer
open_issues_count
Type:integer
organization
Type:github.Organization.Organization
owner
Type:github.NamedUser.NamedUser
parent
Type:github.Repository.Repository
permissions
Type:github.Permissions.Permissions
private
Type:bool
pulls_url
Type:string
pushed_at
Type:datetime.datetime
size
Type:integer
source
Type:github.Repository.Repository
ssh_url
Type:string
stargazers_count
Type:integer
stargazers_url
Type:string
statuses_url
Type:string
subscribers_url
Type:string
subscribers_count
Type:integer
subscription_url
Type:string
svn_url
Type:string
tags_url
Type:string
teams_url
Type:string
topics
Type:list of strings
trees_url
Type:string
updated_at
Type:datetime.datetime
url
Type:string
watchers
Type:integer
watchers_count
Type:integer
add_to_collaborators(collaborator, permission=NotSet)
Calls:

PUT /repos/:owner/:repo/collaborators/:user

Parameters:
Return type:

None

get_collaborator_permission(collaborator)
Calls:GET /repos/:owner/:repo/collaborators/:username/permission
Parameters:collaborator – string or github.NamedUser.NamedUser
Return type:string
compare(base, head)
Calls:

GET /repos/:owner/:repo/compare/:base…:head

Parameters:
  • base – string
  • head – string
Return type:

github.Comparison.Comparison

create_git_blob(content, encoding)
Calls:

POST /repos/:owner/:repo/git/blobs

Parameters:
  • content – string
  • encoding – string
Return type:

github.GitBlob.GitBlob

create_git_commit(message, tree, parents, author=NotSet, committer=NotSet)
Calls:

POST /repos/:owner/:repo/git/commits

Parameters:
Return type:

github.GitCommit.GitCommit

create_git_ref(ref, sha)
Calls:

POST /repos/:owner/:repo/git/refs

Parameters:
  • ref – string
  • sha – string
Return type:

github.GitRef.GitRef

create_git_release(tag, name, message, draft=False, prerelease=False, target_commitish=NotSet)
Calls:

POST /repos/:owner/:repo/releases

Parameters:
Return type:

github.GitRelease.GitRelease

create_git_tag(tag, message, object, type, tagger=NotSet)
Calls:

POST /repos/:owner/:repo/git/tags

Parameters:
Return type:

github.GitTag.GitTag

create_git_tree(tree, base_tree=NotSet)
Calls:

POST /repos/:owner/:repo/git/trees

Parameters:
Return type:

github.GitTree.GitTree

create_hook(name, config, events=NotSet, active=NotSet)
Calls:

POST /repos/:owner/:repo/hooks

Parameters:
  • name – string
  • config – dict
  • events – list of string
  • active – bool
Return type:

github.Hook.Hook

create_issue(title, body=NotSet, assignee=NotSet, milestone=NotSet, labels=NotSet, assignees=NotSet)
Calls:

POST /repos/:owner/:repo/issues

Parameters:
Return type:

github.Issue.Issue

create_key(title, key, read_only=False)
Calls:

POST /repos/:owner/:repo/keys

Parameters:
  • title – string
  • key – string
  • read_only – bool
Return type:

github.RepositoryKey.RepositoryKey

create_label(name, color, description=NotSet)
Calls:

POST /repos/:owner/:repo/labels

Parameters:
  • name – string
  • color – string
  • description – string
Return type:

github.Label.Label

create_milestone(title, state=NotSet, description=NotSet, due_on=NotSet)
Calls:

POST /repos/:owner/:repo/milestones

Parameters:
  • title – string
  • state – string
  • description – string
  • due_on – datetime
Return type:

github.Milestone.Milestone

create_project(name, body=NotSet)

calls: POST /repos/:owner/:repo/projects :param name: string :param body: string

create_pull(*args, **kwds)
Calls:

POST /repos/:owner/:repo/pulls

Parameters:
  • title – string
  • body – string
  • issuegithub.Issue.Issue
  • base – string
  • head – string
  • maintainer_can_modify – bool
Return type:

github.PullRequest.PullRequest

create_source_import(vcs, vcs_url, vcs_username=NotSet, vcs_password=NotSet)
Calls:

PUT /repos/:owner/:repo/import

Parameters:
  • vcs – string
  • vcs_url – string
  • vcs_username – string
  • vcs_password – string
Return type:

github.SourceImport.SourceImport

delete()
Calls:DELETE /repos/:owner/:repo
Return type:None
edit(name=None, description=NotSet, homepage=NotSet, private=NotSet, has_issues=NotSet, has_projects=NotSet, has_wiki=NotSet, has_downloads=NotSet, default_branch=NotSet, allow_squash_merge=NotSet, allow_merge_commit=NotSet, allow_rebase_merge=NotSet, archived=NotSet)
Calls:

PATCH /repos/:owner/:repo

Parameters:
  • name – string
  • description – string
  • homepage – string
  • private – bool
  • has_issues – bool
  • has_projects – bool
  • has_wiki – bool
  • has_downloads – bool
  • default_branch – string
  • allow_squash_merge – bool
  • allow_merge_commit – bool
  • allow_rebase_merge – bool
  • archived – bool. Unarchiving repositories is currently not supported through API (https://developer.github.com/v3/repos/#edit)
Return type:

None

Calls:

GET /repos/:owner/:repo/:archive_format/:ref

Parameters:
  • archive_format – string
  • ref – string
Return type:

string

get_assignees()
Calls:GET /repos/:owner/:repo/assignees
Return type:github.PaginatedList.PaginatedList of github.NamedUser.NamedUser
get_branch(branch)
Calls:GET /repos/:owner/:repo/branches/:branch
Parameters:branch – string
Return type:github.Branch.Branch
get_branches()
Calls:GET /repos/:owner/:repo/branches
Return type:github.PaginatedList.PaginatedList of github.Branch.Branch
get_collaborators(affiliation=NotSet)
Calls:GET /repos/:owner/:repo/collaborators
Parameters:affiliation – string
Return type:github.PaginatedList.PaginatedList of github.NamedUser.NamedUser
get_comment(id)
Calls:GET /repos/:owner/:repo/comments/:id
Parameters:id – integer
Return type:github.CommitComment.CommitComment
get_comments()
Calls:GET /repos/:owner/:repo/comments
Return type:github.PaginatedList.PaginatedList of github.CommitComment.CommitComment
get_commit(sha)
Calls:GET /repos/:owner/:repo/commits/:sha
Parameters:sha – string
Return type:github.Commit.Commit
get_commits(sha=NotSet, path=NotSet, since=NotSet, until=NotSet, author=NotSet)
Calls:

GET /repos/:owner/:repo/commits

Parameters:
Return type:

github.PaginatedList.PaginatedList of github.Commit.Commit

get_contents(path, ref=NotSet)
Calls:

GET /repos/:owner/:repo/contents/:path

Parameters:
  • path – string
  • ref – string
Return type:

github.ContentFile.ContentFile

get_top_referrers()
Calls:GET /repos/:owner/:repo/traffic/popular/referrers
Return type:list of github.Referrer.Referrer
get_top_paths()
Calls:GET /repos/:owner/:repo/traffic/popular/paths
Return type:list of github.Path.Path
get_views_traffic(per=NotSet)
Calls:GET /repos/:owner/:repo/traffic/views
Parameters:per – string, must be one of day or week, day by default
Return type:None or list of github.View.View
get_clones_traffic(per=NotSet)
Calls:GET /repos/:owner/:repo/traffic/clones
Parameters:per – string, must be one of day or week, day by default
Return type:None or list of github.Clone.Clone
get_projects(state=NotSet)
Calls:GET /repos/:owner/:repo/projects
Return type:github.PaginatedList.PaginatedList of github.Project.Project
Parameters:state – string
create_file(path, message, content, branch=NotSet, committer=NotSet, author=NotSet)

Create a file in this repository.

Calls:

PUT /repos/:owner/:repo/contents/:path

Parameters:
  • path – string, (required), path of the file in the repository
  • message – string, (required), commit message
  • content – string, (required), the actual data in the file
  • branch – string, (optional), branch to create the commit on. Defaults to the default branch of the repository
  • committer – InputGitAuthor, (optional), if no information is given the authenticated user’s information will be used. You must specify both a name and email.
  • author – InputGitAuthor, (optional), if omitted this will be filled in with committer information. If passed, you must specify both a name and email.
Return type:

{ ‘content’: ContentFile:, ‘commit’: Commit}

update_file(path, message, content, sha, branch=NotSet, committer=NotSet, author=NotSet)

This method updates a file in a repository

Calls:

PUT /repos/:owner/:repo/contents/:path

Parameters:
  • path – string, Required. The content path.
  • message – string, Required. The commit message.
  • content – string, Required. The updated file content, Base64 encoded.
  • sha – string, Required. The blob SHA of the file being replaced.
  • branch – string. The branch name. Default: the repository’s default branch (usually master)
  • committer – InputGitAuthor, (optional), if no information is given the authenticated user’s information will be used. You must specify both a name and email.
  • author – InputGitAuthor, (optional), if omitted this will be filled in with committer information. If passed, you must specify both a name and email.
Return type:

{ ‘content’: ContentFile:, ‘commit’: Commit}

delete_file(path, message, sha, branch=NotSet, committer=NotSet, author=NotSet)

This method deletes a file in a repository

Calls:

DELETE /repos/:owner/:repo/contents/:path

Parameters:
  • path – string, Required. The content path.
  • message – string, Required. The commit message.
  • sha – string, Required. The blob SHA of the file being replaced.
  • branch – string. The branch name. Default: the repository’s default branch (usually master)
  • committer – InputGitAuthor, (optional), if no information is given the authenticated user’s information will be used. You must specify both a name and email.
  • author – InputGitAuthor, (optional), if omitted this will be filled in with committer information. If passed, you must specify both a name and email.
Return type:

{ ‘content’: null:, ‘commit’: Commit}

get_dir_contents(path, ref=NotSet)
Calls:

GET /repos/:owner/:repo/contents/:path

Parameters:
  • path – string
  • ref – string
Return type:

list of github.ContentFile.ContentFile

get_contributors(anon=NotSet)
Calls:GET /repos/:owner/:repo/contributors
Parameters:anon – string
Return type:github.PaginatedList.PaginatedList of github.NamedUser.NamedUser
get_download(id)
Calls:GET /repos/:owner/:repo/downloads/:id
Parameters:id – integer
Return type:github.Download.Download
get_downloads()
Calls:GET /repos/:owner/:repo/downloads
Return type:github.PaginatedList.PaginatedList of github.Download.Download
get_events()
Calls:GET /repos/:owner/:repo/events
Return type:github.PaginatedList.PaginatedList of github.Event.Event
get_forks()
Calls:GET /repos/:owner/:repo/forks
Return type:github.PaginatedList.PaginatedList of github.Repository.Repository
get_git_blob(sha)
Calls:GET /repos/:owner/:repo/git/blobs/:sha
Parameters:sha – string
Return type:github.GitBlob.GitBlob
get_git_commit(sha)
Calls:GET /repos/:owner/:repo/git/commits/:sha
Parameters:sha – string
Return type:github.GitCommit.GitCommit
get_git_ref(ref)
Calls:GET /repos/:owner/:repo/git/refs/:ref
Parameters:ref – string
Return type:github.GitRef.GitRef
get_git_refs()
Calls:GET /repos/:owner/:repo/git/refs
Return type:github.PaginatedList.PaginatedList of github.GitRef.GitRef
get_git_tag(sha)
Calls:GET /repos/:owner/:repo/git/tags/:sha
Parameters:sha – string
Return type:github.GitTag.GitTag
get_git_tree(sha, recursive=NotSet)
Calls:

GET /repos/:owner/:repo/git/trees/:sha

Parameters:
  • sha – string
  • recursive – bool
Return type:

github.GitTree.GitTree

get_hook(id)
Calls:GET /repos/:owner/:repo/hooks/:id
Parameters:id – integer
Return type:github.Hook.Hook
get_hooks()
Calls:GET /repos/:owner/:repo/hooks
Return type:github.PaginatedList.PaginatedList of github.Hook.Hook
get_issue(number)
Calls:GET /repos/:owner/:repo/issues/:number
Parameters:number – integer
Return type:github.Issue.Issue
get_issues(milestone=NotSet, state=NotSet, assignee=NotSet, mentioned=NotSet, labels=NotSet, sort=NotSet, direction=NotSet, since=NotSet, creator=NotSet)
Calls:

GET /repos/:owner/:repo/issues

Parameters:
Return type:

github.PaginatedList.PaginatedList of github.Issue.Issue

get_issues_comments(sort=NotSet, direction=NotSet, since=NotSet)
Calls:

GET /repos/:owner/:repo/issues/comments

Parameters:
  • sort – string
  • direction – string
  • since – datetime.datetime
Return type:

github.PaginatedList.PaginatedList of github.IssueComment.IssueComment

get_issues_event(id)
Calls:GET /repos/:owner/:repo/issues/events/:id
Parameters:id – integer
Return type:github.IssueEvent.IssueEvent
get_issues_events()
Calls:GET /repos/:owner/:repo/issues/events
Return type:github.PaginatedList.PaginatedList of github.IssueEvent.IssueEvent
get_key(id)
Calls:GET /repos/:owner/:repo/keys/:id
Parameters:id – integer
Return type:github.RepositoryKey.RepositoryKey
get_keys()
Calls:GET /repos/:owner/:repo/keys
Return type:github.PaginatedList.PaginatedList of github.RepositoryKey.RepositoryKey
get_label(name)
Calls:GET /repos/:owner/:repo/labels/:name
Parameters:name – string
Return type:github.Label.Label
get_labels()
Calls:GET /repos/:owner/:repo/labels
Return type:github.PaginatedList.PaginatedList of github.Label.Label
get_languages()
Calls:GET /repos/:owner/:repo/languages
Return type:dict of string to integer
get_license()
Calls:GET /repos/:owner/:repo/license
Return type:github.ContentFile.ContentFile
get_milestone(number)
Calls:GET /repos/:owner/:repo/milestones/:number
Parameters:number – integer
Return type:github.Milestone.Milestone
get_milestones(state=NotSet, sort=NotSet, direction=NotSet)
Calls:

GET /repos/:owner/:repo/milestones

Parameters:
  • state – string
  • sort – string
  • direction – string
Return type:

github.PaginatedList.PaginatedList of github.Milestone.Milestone

get_network_events()
Calls:GET /networks/:owner/:repo/events
Return type:github.PaginatedList.PaginatedList of github.Event.Event
get_pull(number)
Calls:GET /repos/:owner/:repo/pulls/:number
Parameters:number – integer
Return type:github.PullRequest.PullRequest
get_pulls(state=NotSet, sort=NotSet, direction=NotSet, base=NotSet, head=NotSet)
Calls:

GET /repos/:owner/:repo/pulls

Parameters:
  • state – string
  • sort – string
  • direction – string
  • base – string
  • head – string
Return type:

github.PaginatedList.PaginatedList of github.PullRequest.PullRequest

get_pulls_comments(sort=NotSet, direction=NotSet, since=NotSet)
Calls:

GET /repos/:owner/:repo/pulls/comments

Parameters:
  • sort – string
  • direction – string
  • since – datetime.datetime
Return type:

github.PaginatedList.PaginatedList of github.PullRequestComment.PullRequestComment

get_pulls_review_comments(sort=NotSet, direction=NotSet, since=NotSet)
Calls:

GET /repos/:owner/:repo/pulls/comments

Parameters:
  • sort – string
  • direction – string
  • since – datetime.datetime
Return type:

github.PaginatedList.PaginatedList of github.PullRequestComment.PullRequestComment

get_readme(ref=NotSet)
Calls:GET /repos/:owner/:repo/readme
Parameters:ref – string
Return type:github.ContentFile.ContentFile
get_source_import()
Calls:GET /repos/:owner/:repo/import
Return type:github.SourceImport.SourceImport
get_stargazers()
Calls:GET /repos/:owner/:repo/stargazers
Return type:github.PaginatedList.PaginatedList of github.NamedUser.NamedUser
get_stargazers_with_dates()
Calls:GET /repos/:owner/:repo/stargazers
Return type:github.PaginatedList.PaginatedList of github.Stargazer.Stargazer
get_stats_contributors()
Calls:GET /repos/:owner/:repo/stats/contributors
Return type:None or list of github.StatsContributor.StatsContributor
get_stats_commit_activity()
Calls:GET /repos/:owner/:repo/stats/commit_activity
Return type:None or list of github.StatsCommitActivity.StatsCommitActivity
get_stats_code_frequency()
Calls:GET /repos/:owner/:repo/stats/code_frequency
Return type:None or list of github.StatsCodeFrequency.StatsCodeFrequency
get_stats_participation()
Calls:GET /repos/:owner/:repo/stats/participation
Return type:None or github.StatsParticipation.StatsParticipation
get_stats_punch_card()
Calls:GET /repos/:owner/:repo/stats/punch_card
Return type:None or github.StatsPunchCard.StatsPunchCard
get_subscribers()
Calls:GET /repos/:owner/:repo/subscribers
Return type:github.PaginatedList.PaginatedList of github.NamedUser.NamedUser
get_tags()
Calls:GET /repos/:owner/:repo/tags
Return type:github.PaginatedList.PaginatedList of github.Tag.Tag
get_releases()
Calls:GET /repos/:owner/:repo/releases
Return type:github.PaginatedList.PaginatedList of github.GitRelease.GitRelease
get_release(id)
Calls:GET /repos/:owner/:repo/releases/:id
Parameters:id – int (release id), str (tag name)
Return type:None or github.GitRelease.GitRelease
get_latest_release()
Calls:GET /repos/:owner/:repo/releases/latest
Return type:github.GitRelease.GitRelease
get_teams()
Calls:GET /repos/:owner/:repo/teams
Return type:github.PaginatedList.PaginatedList of github.Team.Team
get_topics()
Calls:GET /repos/:owner/:repo/topics
Return type:list of strings
get_watchers()
Calls:GET /repos/:owner/:repo/watchers
Return type:github.PaginatedList.PaginatedList of github.NamedUser.NamedUser
has_in_assignees(assignee)
Calls:GET /repos/:owner/:repo/assignees/:assignee
Parameters:assignee – string or github.NamedUser.NamedUser
Return type:bool
has_in_collaborators(collaborator)
Calls:GET /repos/:owner/:repo/collaborators/:user
Parameters:collaborator – string or github.NamedUser.NamedUser
Return type:bool
legacy_search_issues(state, keyword)
Calls:

GET /legacy/issues/search/:owner/:repository/:state/:keyword

Parameters:
  • state – “open” or “closed”
  • keyword – string
Return type:

github.PaginatedList.PaginatedList of github.Issue.Issue

mark_notifications_as_read(last_read_at=datetime.datetime(2019, 5, 7, 2, 47, 54, 378181))
Calls:PUT /repos/:owner/:repo/notifications
Parameters:last_read_at – datetime
merge(base, head, commit_message=NotSet)
Calls:

POST /repos/:owner/:repo/merges

Parameters:
  • base – string
  • head – string
  • commit_message – string
Return type:

github.Commit.Commit

replace_topics(topics)
Calls:PUT /repos/:owner/:repo/topics
Parameters:topics – list of strings
Return type:None
remove_from_collaborators(collaborator)
Calls:DELETE /repos/:owner/:repo/collaborators/:user
Parameters:collaborator – string or github.NamedUser.NamedUser
Return type:None
subscribe_to_hub(event, callback, secret=NotSet)
Calls:

POST /hub

Parameters:
  • event – string
  • callback – string
  • secret – string
Return type:

None

unsubscribe_from_hub(event, callback)
Calls:

POST /hub

Parameters:
  • event – string
  • callback – string
  • secret – string
Return type:

None