Repository

Repository

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

Constructor

new Repository(fullname, authopt, apiBaseopt)

Create a Repository.

Source:
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

Methods

_getContentObject(content) → {Object}

Get the object that represents the provided content

Source:
Parameters:
Name Type Description
content string | Buffer | Blob

the content to send to the server

Returns:
Type:
Object

the representation of content for the GitHub API

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

Add a commit to the repository

Source:
See:
Parameters:
Name Type Attributes Description
parent string

the SHA of the parent commit

tree string

the SHA of the tree for this commit

message string

the commit message

options Object <optional>

commit options

Name Type Attributes Description
author Object <optional>

the author of the commit

commiter Object <optional>

the committer

cb Requestable.callback

will receive the commit that is created

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

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

Compare two branches/commits/repositories

Source:
See:
Parameters:
Name Type Description
base string

the base commit

head string

the head commit

cb Requestable.callback

will receive the comparison

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

createBlob(content, cb) → {Promise}

Create a blob

Source:
See:
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

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

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

Create a new branch from an existing branch.

Source:
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

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

createHook(options, cb) → {Promise}

Add a new hook to the repository

Source:
See:
Parameters:
Name Type Description
options Object

the configuration describing the new hook

cb Requestable.callback

will receive the new webhook

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

createKey(options, cb) → {Promise}

Add a new deploy key to the repository

Source:
See:
Parameters:
Name Type Description
options Object

the configuration describing the new deploy key

cb Requestable.callback

will receive the new deploy key

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

createProject(options, cb) → {Promise}

Create a new project

Source:
See:
Parameters:
Name Type Description
options Object

the description of the project

cb Requestable.callback

will receive the newly created project

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

createPullRequest(options, cb) → {Promise}

Create a new pull request

Source:
See:
Parameters:
Name Type Description
options Object

the pull request description

cb Requestable.callback

will receive the new pull request

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

createRef(options, cbopt) → {Promise}

Create a reference

Source:
See:
Parameters:
Name Type Attributes Description
options Object

the object describing the ref

cb Requestable.callback <optional>

will receive the ref

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

createRelease(options, cb) → {Promise}

Create a new release

Source:
See:
Parameters:
Name Type Description
options Object

the description of the release

cb Requestable.callback

will receive the newly created release

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

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

Create a new tree in git

Source:
See:
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

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

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

Delete a file from a branch

Source:
See:
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

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

deleteHook(id, cb) → {Promise}

Delete a webhook

Source:
See:
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

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

deleteKey(id, cb) → {Promise}

Delete a deploy key

Source:
See:
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

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

deleteRef(ref, cbopt) → {Promise}

Delete a reference

Source:
See:
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

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

deleteRelease(id, cb) → {Promise}

Delete a release

Source:
See:
Parameters:
Name Type Description
id string

the release to be deleted

cb Requestable.callback

will receive true if the operation is successful

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

deleteRepo(cbopt) → {Promise}

Delete a repository

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

will receive true if the request is successful

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

fork(cb) → {Promise}

Fork a repository

Source:
See:
Parameters:
Name Type Description
cb Requestable.callback

will receive the information about the newly created fork

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

forkToOrg(org, cb) → {Promise}

Fork a repository to an organization

Source:
See:
Parameters:
Name Type Description
org String

organization where you'd like to create the fork.

cb Requestable.callback

will receive the information about the newly created fork

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

getBlob(sha, cb) → {Promise}

Get a raw blob from the repository

Source:
See:
Parameters:
Name Type Description
sha string

the sha of the blob to fetch

cb Requestable.callback

will receive the blob from the API

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

getBranch(branch, cb) → {Promise}

Get a single branch

Source:
See:
Parameters:
Name Type Description
branch string

the name of the branch to fetch

cb Requestable.callback

will receive the branch from the API

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

getCollaborators(cb) → {Promise}

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

Source:
See:
Parameters:
Name Type Description
cb Requestable.callback

will receive the list of collaborators

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

getCommit(sha, cb) → {Promise}

Get a commit from the repository

Source:
See:
Parameters:
Name Type Description
sha string

the sha for the commit to fetch

cb Requestable.callback

will receive the commit data

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

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

Get the contents of a repository

Source:
See:
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

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

getContributors(cb) → {Promise}

List the contributors to the repository

Source:
See:
Parameters:
Name Type Description
cb Requestable.callback

will receive the list of contributors

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

getContributorStats(cb) → {Promise}

List the contributor stats to the repository

Source:
See:
Parameters:
Name Type Description
cb Requestable.callback

will receive the list of contributors

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

getDetails(cb) → {Promise}

Get information about the repository

Source:
See:
Parameters:
Name Type Description
cb Requestable.callback

will receive the information about the repository

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

getHook(id, cb) → {Promise}

Get a hook for the repository

Source:
See:
Parameters:
Name Type Description
id number

the id of the webook

cb Requestable.callback

will receive the details of the webook

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

getKey(id, cb) → {Promise}

Get a deploy key for the repository

Source:
See:
Parameters:
Name Type Description
id number

the id of the deploy key

cb Requestable.callback

will receive the details of the deploy key

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

getPullRequest(number, cbopt) → {Promise}

Get information about a specific pull request

Source:
See:
Parameters:
Name Type Attributes Description
number number

the PR you wish to fetch

cb Requestable.callback <optional>

will receive the PR from the API

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

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

Get the README of a repository

Source:
See:
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

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

getRef(ref, cbopt) → {Promise}

Get a reference

Source:
See:
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

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

getRelease(id, cb) → {Promise}

Get information about a release

Source:
See:
Parameters:
Name Type Description
id string

the id of the release

cb Requestable.callback

will receive the release information

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

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

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

Source:
See:
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

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

getSingleCommit(ref, cb) → {Promise}

Gets a single commit information for a repository

Source:
See:
Parameters:
Name Type Description
ref string

the reference for the commit-ish

cb Requestable.callback

will receive the commit information

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

getTree(treeSHA, cb) → {Promise}

Get a description of a git tree

Source:
See:
Parameters:
Name Type Description
treeSHA string

the SHA of the tree to fetch

cb Requestable.callback

will receive the callback data

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

isCollaborator(username, cb) → {Promise}

Check if a user is a collaborator on the repository

Source:
See:
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

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

isStarred(cb) → {Promise}

Check if a repository is starred by you

Source:
See:
Parameters:
Name Type Description
cb Requestable.callback

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

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

listBranches(cb) → {Promise}

List all the branches for the repository

Source:
See:
Parameters:
Name Type Description
cb Requestable.callback

will receive the list of branches

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

listCommits(optionsopt, cb) → {Promise}

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

Source:
See:
Parameters:
Name Type Attributes Description
options Object <optional>

the filtering options for commits

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

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

listForks(cb) → {Promise}

List a repository's forks

Source:
See:
Parameters:
Name Type Description
cb Requestable.callback

will receive the list of repositories forked from this one

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

listHooks(cb) → {Promise}

List the hooks for the repository

Source:
See:
Parameters:
Name Type Description
cb Requestable.callback

will receive the list of hooks

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

listKeys(cb) → {Promise}

List the deploy keys for the repository

Source:
See:
Parameters:
Name Type Description
cb Requestable.callback

will receive the list of deploy keys

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

listProjects(cbopt) → {Promise}

Get information about all projects

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

will receive the list of projects

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

listPullRequestFiles(number, cbopt) → {Promise}

List the files of a specific pull request

Source:
See:
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

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

listPullRequests(options, cbopt) → {Promise}

List the open pull requests on the repository

Source:
See:
Parameters:
Name Type Attributes Description
options Object

options to filter the search

cb Requestable.callback <optional>

will receive the list of PRs

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

listReleases(cb) → {Promise}

Get information about all releases

Source:
See:
Parameters:
Name Type Description
cb Requestable.callback

will receive the release information

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

listStatuses(sha, cb) → {Promise}

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

Source:
See:
Parameters:
Name Type Description
sha string

the sha, branch, or tag to get statuses for

cb Requestable.callback

will receive the list of statuses

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

listTags(cbopt) → {Promise}

List the tags on a repository

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

will receive the tag data

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

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

Merge a pull request

Source:
See:
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

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

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

Change all references in a repo from oldPath to new_path

Source:
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

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

star(cb) → {Promise}

Star a repository

Source:
See:
Parameters:
Name Type Description
cb Requestable.callback

will receive true if the repository is starred

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

unstar(cb) → {Promise}

Unstar a repository

Source:
See:
Parameters:
Name Type Description
cb Requestable.callback

will receive true if the repository is unstarred

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

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

Update a ref

Source:
See:
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

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

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

Edit an existing webhook

Source:
See:
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

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

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

Update a pull request

Source:
See:
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

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

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

Edit a release

Source:
See:
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

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

updateRepository(options, cb) → {Promise}

Update repository information

Source:
See:
Parameters:
Name Type Description
options object

New parameters that will be set to the repository

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

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

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

Update commit status

Source:
See:
Parameters:
Name Type Description
commitSHA string

the SHA of the commit that should be updated

options object

Commit status parameters

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

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

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

Update a tree in Git

Deprecated:
Source:
See:
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

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

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

Write a file to the repository

Source:
See:
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

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

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