From 9bfbdaa0f0fa296c72e8a9e724bc15a548074240 Mon Sep 17 00:00:00 2001 From: Shigma <1700011071@pku.edu.cn> Date: Thu, 3 Sep 2020 02:44:53 +0800 Subject: [PATCH] feat(github): optimize pr open output --- packages/plugin-github/src/events.ts | 7 +++++-- packages/plugin-github/tests/index.snap.js | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/plugin-github/src/events.ts b/packages/plugin-github/src/events.ts index 7d27cb75ce..bd9a6689e8 100644 --- a/packages/plugin-github/src/events.ts +++ b/packages/plugin-github/src/events.ts @@ -103,12 +103,15 @@ export function addListeners(on: (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, diff --git a/packages/plugin-github/tests/index.snap.js b/packages/plugin-github/tests/index.snap.js index d16a678a00..fe285f55c5 100644 --- a/packages/plugin-github/tests/index.snap.js +++ b/packages/plugin-github/tests/index.snap.js @@ -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