From 6868dbdc8f0fcfe19ccd7a0da52725978f0a63f9 Mon Sep 17 00:00:00 2001 From: Jeffery Date: Fri, 3 Jul 2026 11:22:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(gitea):=20diff=20=E9=81=8E=E6=BF=BE?= =?UTF-8?q?=E6=8E=92=E9=99=A4=20node=5Fmodules=20=E8=88=87=20lock=20?= =?UTF-8?q?=E6=AA=94=EF=BC=8C=E9=81=BF=E5=85=8D=E8=B6=85=E5=87=BA=20LLM=20?= =?UTF-8?q?=E8=BC=B8=E5=85=A5=E4=B8=8A=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gitea.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gitea.js b/src/gitea.js index 3f06b0a..ea6db83 100644 --- a/src/gitea.js +++ b/src/gitea.js @@ -54,6 +54,9 @@ export async function getPRDiff() { '.github/', 'README.md', 'TODO.md', + 'package-lock.json', + 'src/package-lock.json', + 'dist/', ]); } @@ -126,13 +129,16 @@ export async function shouldSkipBotCommit({ sha = PR_HEAD_SHA || process.env.GIT * @param {string[]} excludePrefixes - 要排除的路徑前綴陣列(資料夾以 `/` 結尾,如 `.gitea/`)。 * @returns {string} 過濾後重新接合的 diff 文字。 */ -export function filterDiff(diff, excludePrefixes) { +export function filterDiff(diff, excludePrefixes = []) { return diff.split(/(?=^diff --git )/m) - .filter(block => !excludePrefixes.some(p => { - const prefix = `diff --git a/${p}`; - const singleFile = `diff --git a/${p} b/${p}`; - return block.startsWith(prefix) || block.startsWith(singleFile); - })) + .filter(block => { + const m = block.match(/^diff --git a\/(.+?) b\//); + const path = m ? m[1] : ''; + if (!path) return true; + // 一律排除任何深度的 node_modules:vendored 依賴不是審查對象,且會撐爆 LLM 輸入上限。 + if (/(^|\/)node_modules\//.test(path)) return false; + return !excludePrefixes.some(p => path === p || path.startsWith(p)); + }) .join(''); }