Skip to content

Commit

Permalink
feat(github): optimize pr open output
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Sep 2, 2020
1 parent 89cda84 commit 9bfbdaa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions packages/plugin-github/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,15 @@ export function addListeners(on: <T extends EventNames.All>(event: T, handler: E
})

on('pull_request.opened', ({ repository, pull_request }) => {
const { full_name } = repository
const { full_name, owner } = repository
const { user, html_url, issue_url, comments_url, base, head, body, number } = pull_request
if (user.type === 'bot') return

const prefix = new RegExp(`^${owner.login}:`)
const baseLabel = base.label.replace(prefix, '')
const headLabel = head.label.replace(prefix, '')
return [[
`[GitHub] ${user.login} opened a pull request ${full_name}#${number} (${base.label} <- ${head.label})`,
`[GitHub] ${user.login} opened a pull request ${full_name}#${number} (${baseLabel} <- ${headLabel})`,
formatMarkdown(body),
].join('\n'), {
link: html_url,
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-github/tests/index.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ Ich verstecke Englisch und Chinesisch nicht! Gab es Personen, die mir helfen kan

// URL: https://github.com/koishijs/koishi/pull/20
module.exports[`pull_request.opened.1`] = `
[GitHub] simon300000 opened a pull request koishijs/koishi#20 (koishijs:develop <- koishijs:experimental)
[GitHub] simon300000 opened a pull request koishijs/koishi#20 (develop <- experimental)
Das ist wichtig!`

// URL: https://github.com/koishijs/koishi/pull/90
module.exports[`pull_request.opened.2`] = `
[GitHub] jjyyxx opened a pull request koishijs/koishi#90 (koishijs:mapping <- jjyyxx:mapping)
[GitHub] jjyyxx opened a pull request koishijs/koishi#90 (mapping <- jjyyxx:mapping)
According to \`tsconfig-paths\` documentation ...`

// URL: https://github.com/koishijs/koishi/pull/20#pullrequestreview-345349537
Expand Down

0 comments on commit 9bfbdaa

Please sign in to comment.