Skip to content

merge pull request #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,23 @@ var pullRequestID = 123;
repo.getPull(pullRequestID, function(err, pullRequestInfo) {});
```

Merge a Pull Request.

```js
var pullRequestID = 123;

repo.mergePull({
number: pullRequestID,
// pull request head sha is required to merge a pull request safely
sha: 'f4c3e6d8045ea567cccdc0802e1769a85c6b690c'
}, optionalMessage, function(err, mergeResult){});

// or simply:
repo.getPull(pullRequestID, function(err, pullRequestInfo) {
repo.mergePull(pullRequestInfo, function(err, mergeResult){});
});
```

Create Pull Request.

```js
Expand Down
17 changes: 17 additions & 0 deletions src/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,23 @@
_request('GET', repoPath + '/pulls/' + number, null, cb);
};

// Merge a specific pull request
// -------

this.mergePull = function(pull, message, cb) {
if (typeof message === 'function') {
cb = message;
message = '';
}

var data = {
sha: pull.sha || pull.head.sha,
commit_message: message
};

_request('PUT', repoPath + '/pulls/' + pull.number + '/merge', data, cb);
};

// Retrieve the changes made between base and head
// -------

Expand Down
37 changes: 37 additions & 0 deletions test/test.repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ if (typeof window === 'undefined') { // We're in NodeJS
// jscs:disable
imageB64 = 'iVBORw0KGgoAAAANSUhEUgAAACsAAAAmCAAAAAB4qD3CAAABgElEQVQ4y9XUsUocURQGYN/pAyMWBhGtrEIMiFiooGuVIoYsSBAsRSQvYGFWC4uFhUBYsilXLERQsDA20YAguIbo5PQp3F3inVFTheSvZoavGO79z+mJP0/Pv2nPtlfLpfLq9tljNquO62S8mj1kmy/8nrHm/Xaz1930bt5n1+SzVmyrilItsod9ON0td1V59xR9hwV2HsMRsbfROLo4amzsRcQw5vO2CZPJEU5CM2cXYTCxg7CY2mwIVhK7AkNZYg9g4CqxVwNwkNg6zOTKMQP1xFZgKWeXoJLYdSjl7BysJ7YBIzk7Ap8TewLOE3oOTtIz6y/64bfQn55ZTIAPd2gNTOTurcbzp7z50v1y/Pq2Q7Wczca8vFjG6LvbMo92hiPL96xO+eYVPkVExMdONetFXZ+l+eP9cuV7RER8a9PZwrloTXv2tfv285ZOt4rnrTXlydxCu9sZmGrdN8eXC3ATERHXsHD5wC7ZL3HdsaX9R3bUzlb7YWvn/9ipf93+An8cHsx3W3WHAAAAAElFTkSuQmCC';
imageBlob = new Blob();

// jscs:enable
}
}
Expand Down Expand Up @@ -425,6 +426,42 @@ describe('Creating new Github.Repository', function() {
});
});

it('should merge pull requests on repo', function(done) {

var baseBranch = 'master';
var headBranch = 'pull-request';
var pullRequestTitle = 'Test pull request';
var pullRequestBody = 'This is a test pull request to be merged';

repo.branch(baseBranch, headBranch, function() {
repo.write(headBranch, 'TEST.md', 'THIS IS AN UPDATED TEST THAT WILL GET MERGED', 'Updating test', function() {
repo.createPullRequest(
{
title: pullRequestTitle,
body: pullRequestBody,
base: baseBranch,
head: headBranch
},
function(err, pullRequest, xhr) {
should.not.exist(err);
xhr.should.be.instanceof(XMLHttpRequest);

repo.mergePull(pullRequest, function(err, mergedPullRequest, xhr) {
should.not.exist(err);
xhr.should.be.instanceof(XMLHttpRequest);

should.exist(mergedPullRequest.sha);
should(mergedPullRequest.merged).equal(true);
should.exist(mergedPullRequest.message);

done();
});
}
);
});
});
});

it('should delete a file on the repo', function(done) {
repo.write('master', 'REMOVE-TEST.md', 'THIS IS A TEST', 'Remove test', function(err) {
should.not.exist(err);
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy