Skip to content

Commit

Permalink
feat: merge with specified method
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkomarychev committed Nov 8, 2019
1 parent 7d4baf7 commit c7e7635
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This action will automatically merge your PR once all requirements are met!
# v1 Roadmap

- [x] handle pr reviews
- [ ] various types of merge: squash and rebase
- [x] various types of merge: squash and rebase
- [x] blacklist based on labels
- [x] whitelist based on labels

Expand Down Expand Up @@ -92,4 +92,5 @@ It can hold the following fields:
| field | type | description |
| --- | --- | --- |
| whitelist | string[] | whitelisted labels to perform automerge |
| blacklist | string[] | blacklisted labels to forbid automerge |
| blacklist | string[] | blacklisted labels to forbid automerge |
| method | "merge" \| "squash" \| "rebase" | method to use when merging |
1 change: 1 addition & 0 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11785,6 +11785,7 @@ function mergeIfReady(client, owner, repo, number, sha, config) {
repo,
pull_number: number,
sha,
merge_method: config.method,
});
}
});
Expand Down
10 changes: 9 additions & 1 deletion src/__tests__/mergeIfReady.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ describe('mergeIfReady', () => {
get.mockClear()
canMerge.mockClear()
})
it('merges pr it can be merged', async () => {
it.each`
method
${undefined}
${'merge'}
${'squash'}
${'rebase'}
`('merges pr with $method if it can be merged', async ({ method }) => {
const prNumber = 42
const repo = 'repo'
const owner = 'owner'
Expand All @@ -38,6 +44,7 @@ describe('mergeIfReady', () => {
const config: Config = {
whitelist,
blacklist,
method,
}
await mergeIfReady(
(client as unknown) as Client,
Expand All @@ -61,6 +68,7 @@ describe('mergeIfReady', () => {
repo,
pull_number: prNumber,
sha,
merge_method: method,
})
})
it('does not merge pr if it is not allowed to merge', async () => {
Expand Down
1 change: 1 addition & 0 deletions src/mergeIfReady.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default async function mergeIfReady(
repo,
pull_number: number,
sha,
merge_method: config.method,
})
}
}
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type Client = github.GitHub
export interface Config {
whitelist: string[]
blacklist: string[]
method?: 'merge' | 'squash' | 'rebase'
}

export interface PullRequestPayload {
Expand Down

0 comments on commit c7e7635

Please sign in to comment.