From d18691e5f90892448264229de850ce385e113a5a Mon Sep 17 00:00:00 2001 From: liweijie0812 <674416404@qq.com> Date: Wed, 6 Nov 2024 14:52:38 +0800 Subject: [PATCH] feat: skip bot pr (#42) * feat: skip bot pr * chore: build --- dist/index.js | 6 +++++- src/renderer.ts | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index 15c5a88..4e1c67a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -30023,7 +30023,7 @@ const docsLabel = ['docs', 'doc', 'documentation']; const refactorLabel = ['pref', 'refactor']; exports.CHANGELOG_REG = /-\s([A-Z]+)(?:\(([A-Z\s_-]*)\))?\s*:\s(.+)/gi; exports.PULL_NUMBER_REG = /in\shttps:\/\/github\.com\/.+\/pull\/(\d+)/g; -exports.SKIP_CHANGELOG_REG = /\[x\] 本条 PR 不需要纳入 changelog/i; +exports.SKIP_CHANGELOG_REG = /\[x\] 本条 PR 不需要纳入 Changelog/i; function getPullNumbers(body) { const arr = [...body.matchAll(exports.PULL_NUMBER_REG)]; const pullNumbers = arr.map(n => Number(n[1])); // pr number list @@ -30057,6 +30057,10 @@ function renderMarkdown(pullRequestList) { (0, core_1.startGroup)(`[renderer] pullRequestList`); pullRequestList.forEach((pr) => { pr.body = pr.body ? pr.body : ''; + // 跳过机器人PR + if (pr.user.type === 'Bot') { + return; + } // 不需要纳入 changelog 的 label if (pr.labels.find(l => skipChangelogLabel.includes(l.name))) { (0, core_1.info)(`pr ${pr.number} 有skipChangelogLabel`); diff --git a/src/renderer.ts b/src/renderer.ts index d815df3..efac018 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -10,7 +10,7 @@ const refactorLabel = ['pref', 'refactor'] export const CHANGELOG_REG = /-\s([A-Z]+)(?:\(([A-Z\s_-]*)\))?\s*:\s(.+)/gi export const PULL_NUMBER_REG = /in\shttps:\/\/github\.com\/.+\/pull\/(\d+)/g -export const SKIP_CHANGELOG_REG = /\[x\] 本条 PR 不需要纳入 changelog/i +export const SKIP_CHANGELOG_REG = /\[x\] 本条 PR 不需要纳入 Changelog/i export function getPullNumbers(body: string) { const arr = [...body.matchAll(PULL_NUMBER_REG)] const pullNumbers = arr.map(n => Number(n[1])) // pr number list @@ -46,7 +46,10 @@ export function renderMarkdown(pullRequestList: PullsData[]) { startGroup(`[renderer] pullRequestList`) pullRequestList.forEach((pr) => { pr.body = pr.body ? pr.body : '' - + // 跳过机器人PR + if (pr.user.type === 'Bot') { + return + } // 不需要纳入 changelog 的 label if (pr.labels.find(l => skipChangelogLabel.includes(l.name))) { info(`pr ${pr.number} 有skipChangelogLabel`)