Skip to content

Commit

Permalink
feat(github): support pr squash & rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Oct 25, 2020
1 parent 3ba2079 commit 68178e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/plugin-github/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ export function addListeners(on: <T extends WebhookEvent>(event: T, handler: Eve
close: [issue_url],
link: [html_url],
merge: [url + '/merge'],
rebase: [url + '/merge'],
squash: [url + '/merge'],
react: [issue_url + `/reactions`],
reply: [comments_url],
...replies,
Expand Down
11 changes: 10 additions & 1 deletion packages/plugin-github/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,20 +175,29 @@ export class ReplyHandler {
})
}

merge(url: string) {
merge(url: string, method?: 'merge' | 'squash' | 'rebase') {
const [title] = this.content.split('\n', 1)
const message = this.content.slice(title.length)
return this.github.request({
url,
method: 'PUT',
session: this.session,
body: {
merge_method: method,
commit_title: title.trim(),
commit_message: message.trim(),
},
})
}

rebase(url: string) {
return this.merge(url, 'rebase')
}

squash(url: string) {
return this.merge(url, 'squash')
}

async close(url: string) {
if (this.content) await this.reply(url)
await this.github.request({
Expand Down

0 comments on commit 68178e1

Please sign in to comment.