Repository

Repository

Respository encapsulates the functionality to create, query, and modify files.

Constructor

new Repository(fullname, authopt, apiBaseopt)

Create a Repository.

Parameters:
Name Type Attributes Default Description
fullname string

the full name of the repository

auth Requestable.auth <optional>

information required to authenticate to Github

apiBase string <optional>
https://api.github.com

the base Github API URL

Source:

Methods

_getContentObject(content) → {Object}

Get the object that represents the provided content

Parameters:
Name Type Description
content string | Buffer | Blob

the content to send to the server

Source:
Returns:

the representation of content for the GitHub API

Type
Object

commit(parent, tree, message, cb) → {Promise}

Add a commit to the repository

Parameters:
Name Type Description
parent string

the SHA of the parent commit

tree string

the SHA of the tree for this commit

message string

the commit message

cb Requestable.callback

will receive the commit that is created

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

compareBranches(base, head, cb) → {Promise}

Compare two branches/commits/repositories

Parameters:
Name Type Description
base string

the base commit

head string

the head commit

cb Requestable.callback

will receive the comparison

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

createBlob(content, cb) → {Promise}

Create a blob

Parameters:
Name Type Description
content string | Buffer | Blob

the content to add to the repository

cb Requestable.callback

will receive the details of the created blob

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

createBranch(oldBranchopt, newBranch, cb) → {Promise}

Create a new branch from an existing branch.

Parameters:
Name Type Attributes Default Description
oldBranch string <optional>
master

the name of the existing branch

newBranch string

the name of the new branch

cb Requestable.callback

will receive the commit data for the head of the new branch

Source:
Returns:
  • the promise for the http request
Type
Promise

createHook(options, cb) → {Promise}

Add a new hook to the repository

Parameters:
Name Type Description
options Object

the configuration describing the new hook

cb Requestable.callback

will receive the new webhook

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

createKey(options, cb) → {Promise}

Add a new deploy key to the repository

Parameters:
Name Type Description
options Object

the configuration describing the new deploy key

cb Requestable.callback

will receive the new deploy key

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

createProject(options, cb) → {Promise}

Create a new project

Parameters:
Name Type Description
options Object

the description of the project

cb Requestable.callback

will receive the newly created project

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

createPullRequest(options, cb) → {Promise}

Create a new pull request

Parameters:
Name Type Description
options Object

the pull request description

cb Requestable.callback

will receive the new pull request

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

createRef(options, cbopt) → {Promise}

Create a reference

Parameters:
Name Type Attributes Description
options Object

the object describing the ref

cb Requestable.callback <optional>

will receive the ref

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

createRelease(options, cb) → {Promise}

Create a new release

Parameters:
Name Type Description
options Object

the description of the release

cb Requestable.callback

will receive the newly created release

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

createTree(tree, baseSHA, cb) → {Promise}

Create a new tree in git

Parameters:
Name Type Description
tree Object

the tree to create

baseSHA string

the root sha of the tree

cb Requestable.callback

will receive the new tree that is created

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

deleteFile(branch, path, cb) → {Promise}

Delete a file from a branch

Parameters:
Name Type Description
branch string

the branch to delete from, or the default branch if not specified

path string

the path of the file to remove

cb Requestable.callback

will receive the commit in which the delete occurred

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

deleteHook(id, cb) → {Promise}

Delete a webhook

Parameters:
Name Type Description
id number

the id of the webhook to be deleted

cb Requestable.callback

will receive true if the call is successful

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

deleteKey(id, cb) → {Promise}

Delete a deploy key

Parameters:
Name Type Description
id number

the id of the deploy key to be deleted

cb Requestable.callback

will receive true if the call is successful

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

deleteRef(ref, cbopt) → {Promise}

Delete a reference

Parameters:
Name Type Attributes Description
ref string

the name of the ref to delte

cb Requestable.callback <optional>

will receive true if the request is successful

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

deleteRelease(id, cb) → {Promise}

Delete a release

Parameters:
Name Type Description
id string

the release to be deleted

cb Requestable.callback

will receive true if the operation is successful

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

deleteRepo(cbopt) → {Promise}

Delete a repository

Parameters:
Name Type Attributes Description
cb Requestable.callback <optional>

will receive true if the request is successful

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

fork(cb) → {Promise}

Fork a repository

Parameters:
Name Type Description
cb Requestable.callback

will receive the information about the newly created fork

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

getBlob(sha, cb) → {Promise}

Get a raw blob from the repository

Parameters:
Name Type Description
sha string

the sha of the blob to fetch

cb Requestable.callback

will receive the blob from the API

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

getBranch(branch, cb) → {Promise}

Get a single branch

Parameters:
Name Type Description
branch string

the name of the branch to fetch

cb Requestable.callback

will receive the branch from the API

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

getCollaborators(cb) → {Promise}

List the users who are collaborators on the repository. The currently authenticated user must have push access to use this method

Parameters:
Name Type Description
cb Requestable.callback

will receive the list of collaborators

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

getCommit(sha, cb) → {Promise}

Get a commit from the repository

Parameters:
Name Type Description
sha string

the sha for the commit to fetch

cb Requestable.callback

will receive the commit data

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

getContents(ref, path, raw, cb) → {Promise}

Get the contents of a repository

Parameters:
Name Type Description
ref string

the ref to check

path string

the path containing the content to fetch

raw boolean

true if the results should be returned raw instead of GitHub's normalized format

cb Requestable.callback

will receive the fetched data

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

getContributors(cb) → {Promise}

List the contributors to the repository

Parameters:
Name Type Description
cb Requestable.callback

will receive the list of contributors

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

getContributorStats(cb) → {Promise}

List the contributor stats to the repository

Parameters:
Name Type Description
cb Requestable.callback

will receive the list of contributors

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

getDetails(cb) → {Promise}

Get information about the repository

Parameters:
Name Type Description
cb Requestable.callback

will receive the information about the repository

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

getHook(id, cb) → {Promise}

Get a hook for the repository

Parameters:
Name Type Description
id number

the id of the webook

cb Requestable.callback

will receive the details of the webook

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

getKey(id, cb) → {Promise}

Get a deploy key for the repository

Parameters:
Name Type Description
id number

the id of the deploy key

cb Requestable.callback

will receive the details of the deploy key

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

getPullRequest(number, cbopt) → {Promise}

Get information about a specific pull request

Parameters:
Name Type Attributes Description
number number

the PR you wish to fetch

cb Requestable.callback <optional>

will receive the PR from the API

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

getReadme(ref, raw, cb) → {Promise}

Get the README of a repository

Parameters:
Name Type Description
ref string

the ref to check

raw boolean

true if the results should be returned raw instead of GitHub's normalized format

cb Requestable.callback

will receive the fetched data

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

getRef(ref, cbopt) → {Promise}

Get a reference

Parameters:
Name Type Attributes Description
ref string

the reference to get

cb Requestable.callback <optional>

will receive the reference's refSpec or a list of refSpecs that match ref

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

getRelease(id, cb) → {Promise}

Get information about a release

Parameters:
Name Type Description
id string

the id of the release

cb Requestable.callback

will receive the release information

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

getSha(branchopt, path, cb) → {Promise}

Get tha sha for a particular object in the repository. This is a convenience function

Parameters:
Name Type Attributes Description
branch string <optional>

the branch to look in, or the repository's default branch if omitted

path string

the path of the file or directory

cb Requestable.callback

will receive a description of the requested object, including a SHA property

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

getSingleCommit(ref, cb) → {Promise}

Gets a single commit information for a repository

Parameters:
Name Type Description
ref string

the reference for the commit-ish

cb Requestable.callback

will receive the commit information

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

getTree(treeSHA, cb) → {Promise}

Get a description of a git tree

Parameters:
Name Type Description
treeSHA string

the SHA of the tree to fetch

cb Requestable.callback

will receive the callback data

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

isCollaborator(username, cb) → {Promise}

Check if a user is a collaborator on the repository

Parameters:
Name Type Description
username string

the user to check

cb Requestable.callback

will receive true if the user is a collaborator and false if they are not

Source:
See:
Returns:
  • the promise for the http request {Boolean} [description]
Type
Promise

isStarred(cb) → {Promise}

Check if a repository is starred by you

Parameters:
Name Type Description
cb Requestable.callback

will receive true if the repository is starred and false if the repository is not starred

Source:
See:
Returns:
  • the promise for the http request {Boolean} [description]
Type
Promise

listBranches(cb) → {Promise}

List all the branches for the repository

Parameters:
Name Type Description
cb Requestable.callback

will receive the list of branches

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

listCommits(optionsopt, cb) → {Promise}

List the commits on a repository, optionally filtering by path, author or time range

Parameters:
Name Type Attributes Description
options Object <optional>

the filtering options for commits

Properties
Name Type Attributes Description
sha string <optional>

the SHA or branch to start from

path string <optional>

the path to search on

author string <optional>

the commit author

since Date | string <optional>

only commits after this date will be returned

until Date | string <optional>

only commits before this date will be returned

cb Requestable.callback

will receive the list of commits found matching the criteria

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

listForks(cb) → {Promise}

List a repository's forks

Parameters:
Name Type Description
cb Requestable.callback

will receive the list of repositories forked from this one

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

listHooks(cb) → {Promise}

List the hooks for the repository

Parameters:
Name Type Description
cb Requestable.callback

will receive the list of hooks

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

listKeys(cb) → {Promise}

List the deploy keys for the repository

Parameters:
Name Type Description
cb Requestable.callback

will receive the list of deploy keys

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

listProjects(cbopt) → {Promise}

Get information about all projects

Parameters:
Name Type Attributes Description
cb Requestable.callback <optional>

will receive the list of projects

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

listPullRequestFiles(number, cbopt) → {Promise}

List the files of a specific pull request

Parameters:
Name Type Attributes Description
number number | string

the PR you wish to fetch

cb Requestable.callback <optional>

will receive the list of files from the API

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

listPullRequests(options, cbopt) → {Promise}

List the open pull requests on the repository

Parameters:
Name Type Attributes Description
options Object

options to filter the search

cb Requestable.callback <optional>

will receive the list of PRs

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

listReleases(cb) → {Promise}

Get information about all releases

Parameters:
Name Type Description
cb Requestable.callback

will receive the release information

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

listStatuses(sha, cb) → {Promise}

List the commit statuses for a particular sha, branch, or tag

Parameters:
Name Type Description
sha string

the sha, branch, or tag to get statuses for

cb Requestable.callback

will receive the list of statuses

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

listTags(cbopt) → {Promise}

List the tags on a repository

Parameters:
Name Type Attributes Description
cb Requestable.callback <optional>

will receive the tag data

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

mergePullRequest(number, options, cbopt) → {Promise}

Merge a pull request

Parameters:
Name Type Attributes Description
number number | string

the number of the pull request to merge

options Object

the merge options for the pull request

cb Requestable.callback <optional>

will receive the merge information if the operation is successful

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

move(branch, oldPath, newPath, cb) → {Promise}

Change all references in a repo from oldPath to new_path

Parameters:
Name Type Description
branch string

the branch to carry out the reference change, or the default branch if not specified

oldPath string

original path

newPath string

new reference path

cb Requestable.callback

will receive the commit in which the move occurred

Source:
Returns:
  • the promise for the http request
Type
Promise

star(cb) → {Promise}

Star a repository

Parameters:
Name Type Description
cb Requestable.callback

will receive true if the repository is starred

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

unstar(cb) → {Promise}

Unstar a repository

Parameters:
Name Type Description
cb Requestable.callback

will receive true if the repository is unstarred

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

updateHead(ref, commitSHA, force, cb) → {Promise}

Update a ref

Parameters:
Name Type Description
ref string

the ref to update

commitSHA string

the SHA to point the reference to

force boolean

indicates whether to force or ensure a fast-forward update

cb Requestable.callback

will receive the updated ref back

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

updateHook(id, options, cb) → {Promise}

Edit an existing webhook

Parameters:
Name Type Description
id number

the id of the webhook

options Object

the new description of the webhook

cb Requestable.callback

will receive the updated webhook

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

updatePullRequest(number, options, cbopt) → {Promise}

Update a pull request

Parameters:
Name Type Attributes Description
number number | string

the number of the pull request to update

options Object

the pull request description

cb Requestable.callback <optional>

will receive the pull request information

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

updateRelease(id, options, cb) → {Promise}

Edit a release

Parameters:
Name Type Description
id string

the id of the release

options Object

the description of the release

cb Requestable.callback

will receive the modified release

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

updateRepository(options, cb) → {Promise}

Update repository information

Parameters:
Name Type Description
options object

New parameters that will be set to the repository

Properties
Name Type Attributes Description
name string

Name of the repository

description string <optional>

A short description of the repository

homepage string <optional>

A URL with more information about the repository

private boolean <optional>

Either true to make the repository private, or false to make it public.

has_issues boolean <optional>

Either true to enable issues for this repository, false to disable them.

has_wiki boolean <optional>

Either true to enable the wiki for this repository, false to disable it.

has_downloads boolean <optional>

Either true to enable downloads, false to disable them.

default_branch string <optional>

Updates the default branch for this repository.

cb Requestable.callback

will receive the updated repository back

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

updateStatus(commitSHA, options, cb) → {Promise}

Update commit status

Parameters:
Name Type Description
commitSHA string

the SHA of the commit that should be updated

options object

Commit status parameters

Properties
Name Type Attributes Description
state string

The state of the status. Can be one of: pending, success, error, or failure.

target_url string <optional>

The target URL to associate with this status.

description string <optional>

A short description of the status.

context string <optional>

A string label to differentiate this status among CI systems.

cb Requestable.callback

will receive the updated commit back

Source:
See:
Returns:
  • the promise for the http request
Type
Promise

updateTree(baseTreeSHA, path, blobSHA, cb) → {Promise}

Update a tree in Git

Parameters:
Name Type Description
baseTreeSHA string

the SHA of the tree to update

path string

the path for the new file

blobSHA string

the SHA for the blob to put at path

cb Requestable.callback

will receive the new tree that is created

Deprecated:
Source:
See:
Returns:
  • the promise for the http request
Type
Promise

writeFile(branch, path, content, message, optionsopt, cb) → {Promise}

Write a file to the repository

Parameters:
Name Type Attributes Description
branch string

the name of the branch

path string

the path for the file

content string

the contents of the file

message string

the commit message

options Object <optional>

commit options

Properties
Name Type Attributes Description
author Object <optional>

the author of the commit

commiter Object <optional>

the committer

encode boolean <optional>

true if the content should be base64 encoded

cb Requestable.callback

will receive the new commit

Source:
See:
Returns:
  • the promise for the http request
Type
Promise