-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update squash commit message to include all PR commit authors
- Loading branch information
1 parent
f77754c
commit 0ee8afc
Showing
8 changed files
with
5,232 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// webhook: https://developer.github.com/v3/activity/events/types/#webhook-payload-example-13 | ||
// webhook.issue (pull request): https://developer.github.com/v3/issues/#response | ||
module.exports = { | ||
action: 'created', | ||
issue: { | ||
html_url: 'https://github.com/fusionjs/test-repo/pull/1', | ||
number: 1, | ||
pull_request: { | ||
url: 'https://api.github.com/repos/fusionjs/test-repo/pulls/1', | ||
}, | ||
state: 'open', | ||
title: 'Test PR', | ||
}, | ||
comment: { | ||
body: '!merge', | ||
user: { | ||
login: 'test-user', | ||
type: 'User', | ||
}, | ||
}, | ||
repository: { | ||
name: 'test-repo', | ||
owner: { | ||
login: 'fusionjs', | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// https://developer.github.com/v3/pulls/#list-commits-on-a-pull-request | ||
module.exports = [ | ||
{ | ||
commit: { | ||
author: { | ||
name: 'test-user', | ||
email: '[email protected]', | ||
}, | ||
}, | ||
}, | ||
{ | ||
commit: { | ||
author: { | ||
name: 'test-user2', | ||
email: '[email protected]', | ||
}, | ||
}, | ||
}, | ||
{ | ||
commit: { | ||
author: { | ||
name: 'test-user3', | ||
email: '[email protected]', | ||
}, | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// https://developer.github.com/v3/repos/collaborators/#review-a-users-permission-level | ||
module.exports = { | ||
permission: 'admin', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,58 @@ | ||
/** Copyright (c) 2017 Uber Technologies, Inc. | ||
/** Copyright (c) 2019 Uber Technologies, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/* eslint-env jest */ | ||
|
||
const t = require('assert'); | ||
const nock = require('nock'); | ||
const mergePRApp = require('../index.js'); | ||
const {Probot} = require('probot'); | ||
const fixtures = { | ||
listCommits: require('./__fixtures__/listCommits.js'), | ||
payload: require('./__fixtures__/issue_comment.created.js'), | ||
reviewUserPermissionLevel: require('./__fixtures__/reviewUserPermissionLevel.js'), | ||
}; | ||
|
||
test('dummy test', () => { | ||
t.ok(true, 'dummy assertion passed'); | ||
nock.disableNetConnect(); | ||
|
||
describe('probot-app-merge-pr', () => { | ||
let probot; | ||
|
||
beforeEach(() => { | ||
probot = new Probot({}); | ||
const app = probot.load(mergePRApp); | ||
|
||
// just return a test token | ||
app.app = () => 'test'; | ||
}); | ||
|
||
test('merges the PR with commit authors as co-authors', async () => { | ||
nock('https://api.github.com') | ||
.get('/repos/fusionjs/test-repo/collaborators/test-user/permission') | ||
.reply(200, fixtures.reviewUserPermissionLevel) | ||
.get('/repos/fusionjs/test-repo/contents/.github/merge-pr.yml') | ||
.reply(404) | ||
.get('/repos/fusionjs/test-repo/pulls/1/commits') | ||
.reply(200, fixtures.listCommits); | ||
|
||
const mergeRequest = new Promise(resolve => { | ||
nock('https://api.github.com') | ||
.put('/repos/fusionjs/test-repo/pulls/1/merge', resolve) | ||
.reply(200); | ||
}); | ||
|
||
const expectedMessage = `https://github.com/fusionjs/test-repo/pull/1 | ||
Co-authored-by: test-user2 <[email protected]> | ||
Co-authored-by: test-user3 <[email protected]>`; | ||
|
||
await probot.receive({name: 'issue_comment', payload: fixtures.payload}); | ||
expect(await mergeRequest).toEqual({ | ||
commit_title: 'Test PR', | ||
commit_message: expectedMessage, | ||
merge_method: 'squash', | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.