job51-gitlab-cr-node-jt-1 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/index.js +137 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -181,6 +181,130 @@ class GitLabCodeReviewer {
|
|
|
181
181
|
return false;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
/**
|
|
185
|
+
* 判断文件是否是非代码文件(需要跳过审查)
|
|
186
|
+
* 非代码文件包括:配置文件、文档文件、资源文件、数据文件等
|
|
187
|
+
* @param {string} filePath 文件路径
|
|
188
|
+
* @returns {boolean} 是否是非代码文件
|
|
189
|
+
*/
|
|
190
|
+
isNonCodeFile(filePath) {
|
|
191
|
+
if (!filePath) return false;
|
|
192
|
+
|
|
193
|
+
// 标准化路径(统一使用 / 分隔符)
|
|
194
|
+
const normalizedPath = filePath.replace(/\\/g, '/');
|
|
195
|
+
|
|
196
|
+
// 提取文件名和扩展名
|
|
197
|
+
const fileName = normalizedPath.split('/').pop() || '';
|
|
198
|
+
const ext = fileName.split('.').pop()?.toLowerCase() || '';
|
|
199
|
+
|
|
200
|
+
// 非代码文件扩展名列表
|
|
201
|
+
const nonCodeExtensions = [
|
|
202
|
+
// 配置文件
|
|
203
|
+
'json', // JSON 配置文件(如 package.json, tsconfig.json 等)
|
|
204
|
+
'yaml', 'yml', // YAML 配置文件
|
|
205
|
+
'xml', // XML 配置文件(如 pom.xml, logback.xml 等)
|
|
206
|
+
'properties', // Java Properties 文件
|
|
207
|
+
'toml', // TOML 配置文件
|
|
208
|
+
'ini', // INI 配置文件
|
|
209
|
+
'conf', 'config', // 通用配置文件
|
|
210
|
+
'env', // 环境变量文件
|
|
211
|
+
'editorconfig', // EditorConfig 文件
|
|
212
|
+
'gitignore', // Git ignore 文件
|
|
213
|
+
'gitattributes', // Git attributes 文件
|
|
214
|
+
'dockerignore', // Docker ignore 文件
|
|
215
|
+
|
|
216
|
+
// 文档文件
|
|
217
|
+
'md', 'markdown', // Markdown 文档
|
|
218
|
+
'txt', // 文本文件
|
|
219
|
+
'rst', // reStructuredText 文档
|
|
220
|
+
'adoc', 'asciidoc', // AsciiDoc 文档
|
|
221
|
+
'doc', 'docx', // Word 文档
|
|
222
|
+
'pdf', // PDF 文档
|
|
223
|
+
'changelog', // 变更日志
|
|
224
|
+
'license', // 许可证文件
|
|
225
|
+
'readme', // README 文件(无扩展名情况)
|
|
226
|
+
|
|
227
|
+
// 资源文件
|
|
228
|
+
'png', 'jpg', 'jpeg', 'gif', 'bmp', 'ico', 'svg', 'webp', // 图片
|
|
229
|
+
'woff', 'woff2', 'ttf', 'otf', 'eot', // 字体文件
|
|
230
|
+
'mp3', 'mp4', 'wav', 'avi', 'mov', 'wmv', 'flv', // 音视频文件
|
|
231
|
+
'zip', 'tar', 'gz', 'rar', '7z', 'jar', 'war', // 压缩包
|
|
232
|
+
|
|
233
|
+
// 数据文件
|
|
234
|
+
'csv', // CSV 数据文件
|
|
235
|
+
'xls', 'xlsx', // Excel 文件
|
|
236
|
+
'sql', // SQL 脚本文件(纯数据导出)
|
|
237
|
+
'db', 'sqlite', // 数据库文件
|
|
238
|
+
|
|
239
|
+
// 其他非代码文件
|
|
240
|
+
'sh', 'bat', 'cmd', // 脚本文件(通常只审查业务代码)
|
|
241
|
+
'ps1', // PowerShell 脚本
|
|
242
|
+
'lock', // 锁文件(如 package-lock.json, yarn.lock)
|
|
243
|
+
'map', // Source map 文件
|
|
244
|
+
'log', // 日志文件
|
|
245
|
+
'bak', 'backup', // 备份文件
|
|
246
|
+
'tmp', 'temp', // 临时文件
|
|
247
|
+
'swp', 'swo', // Vim swap 文件
|
|
248
|
+
'DS_Store', // macOS 文件
|
|
249
|
+
];
|
|
250
|
+
|
|
251
|
+
// 检查扩展名是否在非代码列表中
|
|
252
|
+
if (nonCodeExtensions.includes(ext)) {
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// 特殊文件名(无扩展名或特殊命名)
|
|
257
|
+
const specialNonCodeFiles = [
|
|
258
|
+
'LICENSE',
|
|
259
|
+
'LICENSE.txt',
|
|
260
|
+
'LICENSE.md',
|
|
261
|
+
'MIT',
|
|
262
|
+
'Apache',
|
|
263
|
+
'GPL',
|
|
264
|
+
'README',
|
|
265
|
+
'README.txt',
|
|
266
|
+
'README.md',
|
|
267
|
+
'CHANGELOG',
|
|
268
|
+
'CHANGELOG.md',
|
|
269
|
+
'CHANGELOG.txt',
|
|
270
|
+
'CONTRIBUTING',
|
|
271
|
+
'CONTRIBUTING.md',
|
|
272
|
+
'.gitignore',
|
|
273
|
+
'.gitattributes',
|
|
274
|
+
'.editorconfig',
|
|
275
|
+
'.env',
|
|
276
|
+
'.env.local',
|
|
277
|
+
'.env.development',
|
|
278
|
+
'.env.production',
|
|
279
|
+
'.dockerignore',
|
|
280
|
+
'.eslintrc',
|
|
281
|
+
'.prettierrc',
|
|
282
|
+
'.stylelintrc',
|
|
283
|
+
'Makefile',
|
|
284
|
+
'Dockerfile',
|
|
285
|
+
'docker-compose.yml',
|
|
286
|
+
'docker-compose.yaml',
|
|
287
|
+
'Vagrantfile',
|
|
288
|
+
'.travis.yml',
|
|
289
|
+
'Jenkinsfile',
|
|
290
|
+
];
|
|
291
|
+
|
|
292
|
+
// 检查是否是特殊非代码文件
|
|
293
|
+
for (const specialFile of specialNonCodeFiles) {
|
|
294
|
+
if (fileName === specialFile || normalizedPath.endsWith('/' + specialFile)) {
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// 检查隐藏文件(以 . 开头的文件,通常是配置文件)
|
|
300
|
+
if (fileName.startsWith('.') && !fileName.startsWith('.claude')) {
|
|
301
|
+
// .claude 目录下的文件可能包含规则配置,需要审查
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
|
|
184
308
|
/**
|
|
185
309
|
* 获取合并请求的diff信息
|
|
186
310
|
* @param {number} projectId GitLab项目ID
|
|
@@ -445,6 +569,7 @@ class GitLabCodeReviewer {
|
|
|
445
569
|
const allBlocks = [];
|
|
446
570
|
const skippedTestFiles = []; // 记录跳过的测试文件
|
|
447
571
|
const skippedDtoVoFiles = []; // 记录跳过的 DTO/VO 文件
|
|
572
|
+
const skippedNonCodeFiles = []; // 记录跳过的非代码文件
|
|
448
573
|
for (const diff of diffs) {
|
|
449
574
|
const filePath = diff.new_path || diff.old_path;
|
|
450
575
|
|
|
@@ -462,6 +587,13 @@ class GitLabCodeReviewer {
|
|
|
462
587
|
continue; // 跳过 DTO/VO 文件
|
|
463
588
|
}
|
|
464
589
|
|
|
590
|
+
// 检查是否是非代码文件
|
|
591
|
+
if (this.isNonCodeFile(filePath)) {
|
|
592
|
+
debugLog(`跳过非代码文件: ${filePath}`);
|
|
593
|
+
skippedNonCodeFiles.push(filePath);
|
|
594
|
+
continue; // 跳过非代码文件
|
|
595
|
+
}
|
|
596
|
+
|
|
465
597
|
const diffObjects = this.getDiffBlocks(diff);
|
|
466
598
|
for (let i = 0; i < diffObjects.length; i++) {
|
|
467
599
|
// 更新块索引
|
|
@@ -480,6 +612,11 @@ class GitLabCodeReviewer {
|
|
|
480
612
|
infoLog(`已跳过 ${skippedDtoVoFiles.length} 个 DTO/VO 文件: ${skippedDtoVoFiles.join(', ')}`);
|
|
481
613
|
}
|
|
482
614
|
|
|
615
|
+
// 输出跳过的非代码文件统计
|
|
616
|
+
if (skippedNonCodeFiles.length > 0) {
|
|
617
|
+
infoLog(`已跳过 ${skippedNonCodeFiles.length} 个非代码文件: ${skippedNonCodeFiles.join(', ')}`);
|
|
618
|
+
}
|
|
619
|
+
|
|
483
620
|
// 使用线程池控制并发数量
|
|
484
621
|
const results = await this.processWithThreadPool(allBlocks, processBlock, maxConcurrency);
|
|
485
622
|
|