Visitar URL original
merge pull request by benjamine · Pull Request #281 · github-tools/github · GitHub
The Wayback Machine - https://web.archive.org/web/20200920055618/https://github.com/github-tools/github/pull/281
Skip to content
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

merge pull request #281

Closed

Conversation

@benjamine
Copy link

benjamine commented Jan 20, 2016

adding repo.mergePull
docs: https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button

note the unit test isn't really testing a succesful merge (but a failture to merge), given the destructive nature of that action I think that would require mocking of the github API, but that might be a big effort.

ps: this is a pull request to merge pull requests 😮

@benjamine
Copy link
Author

benjamine commented Jan 20, 2016

from #278

@AurelioDeRosa AurelioDeRosa added this to the v0.10.8 milestone Jan 24, 2016
github.js Outdated
// Merge a specific pull request
// -------

this.mergePull = function(pull, message, cb) {

This comment has been minimized.

@AurelioDeRosa

AurelioDeRosa Jan 24, 2016 Member

Since we're using already an object as the first parameter, instead of using overloading I think it's better to add the optional message as a property of the object. If it isn't defined we can use a default message (e.g. empty string).

github.js Outdated
commit_message: message
};

_request('PUT', repoPath + '/pulls/' + pull.number + '/merge', data, function(err, mergeResult, xhr) {

This comment has been minimized.

@AurelioDeRosa

AurelioDeRosa Jan 24, 2016 Member

The anonymous function can be replaced by cb.

@@ -272,14 +273,35 @@ describe('Creating new Github.Repository', function() {
it('should get pull requests on repo', function(done) {
var repo = github.getRepo('michael', 'github');

repo.getPull(153, function(err) {
repo.getPull(153, function(err, pull) {

This comment has been minimized.

@AurelioDeRosa

AurelioDeRosa Jan 24, 2016 Member

Can you remove this change and move it into another PR? This is not related to the merge feature.

@AurelioDeRosa AurelioDeRosa force-pushed the github-tools:master branch from f3bdb04 to bc25f25 Jan 24, 2016
@AurelioDeRosa AurelioDeRosa modified the milestones: 0.12.0, v0.10.8 Jan 24, 2016
@AurelioDeRosa
Copy link
Member

AurelioDeRosa commented Feb 20, 2016

Hi @benjamine. Are you still interested in this PR?

@benjamine
Copy link
Author

benjamine commented Feb 21, 2016

@AurelioDeRosa yes, fixing

@benjamine benjamine force-pushed the benjamine:feature/pull-request-merge branch from fadd687 to 8e1cb4b Feb 21, 2016
@benjamine
Copy link
Author

benjamine commented Feb 21, 2016

@AurelioDeRosa all fixed except for this comment that got lost while rebasing:

Since we're using already an object as the first parameter, instead of using overloading I think it's better to add the optional message as a property of the object. If it isn't defined we can use a default message (e.g. empty string).

the reason why I added message as a separate (optional) argument is that this allows you to send as first paramenter a pull object obtained from getPull (which will probably the most common case, as you can't create that yourself, github forces you to send the head sha to avoid mistakes)
This is shown in the 2nd example I added to README.
Otherwise you'd have to modify the object in the middle (with a parameter that isn't really part of a pull request info).

var expectedDocUrl = 'https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button';

repo.getPull(153, function(err, pull) {
repo.mergePull(pull, function(err) {

This comment has been minimized.

@AurelioDeRosa

AurelioDeRosa Feb 21, 2016 Member

I think we should have a test for the success of the merge of a pull request, not the failure. At the moment the test doesn't verify if the method is working correctly.

This comment has been minimized.

@benjamine

benjamine Feb 21, 2016 Author

I agree, but given there's no mocking of the github API, I don't see a way to do merges in a repeatable, parallel-safe, way.
But maybe the test title could be negative then.

This comment has been minimized.

@AurelioDeRosa

AurelioDeRosa Feb 21, 2016 Member

At the moment we're not doing parallel tests anyway, so the idea here is to create a new PR and then merge it.

This comment has been minimized.

@benjamine

benjamine Feb 21, 2016 Author

I meant parallel in that any user could be running them, locally, or in travis from their forks.
should this create a random commit to a new branch and merge it (with the potential to get conflicts if other is merged in between)?

This comment has been minimized.

@AurelioDeRosa

AurelioDeRosa Feb 21, 2016 Member

No conflict can happen as the repository used is different at every execution of the tests.

This comment has been minimized.

@benjamine

benjamine Feb 22, 2016 Author

oh ok, good to know, well I'll copy from the create pull request test

@AurelioDeRosa
Copy link
Member

AurelioDeRosa commented Feb 21, 2016

I see your point @benjamine and it makes perfect sense. However, I know that in that context a user will not care about the change of the original object with an optional message property. Also, this will help me in the big method refactor I'm planning.

@benjamine
Copy link
Author

benjamine commented Feb 21, 2016

besides side effects, it seems confusing to me, as user, to add a pull.message = ... when it's not PR message you're setting (it's a commit message for the merge of such PR).
unless it's called pull.mergeCommitMessage?

@benjamine benjamine force-pushed the benjamine:feature/pull-request-merge branch from 8e1cb4b to 5481366 Feb 22, 2016
@benjamine benjamine force-pushed the benjamine:feature/pull-request-merge branch from 5481366 to f41ef25 Feb 22, 2016
@clayreimann clayreimann modified the milestones: 1.x, 0.12.0 Apr 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.