feat: 導入 AI 程式碼審查 action 並修正進入點與參數接線 #1
+12
-6
@@ -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('');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user