gitlab-ai-review 3.0.0 → 3.1.0
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 +4 -0
- package/index.js +38 -4
- package/package.json +2 -2
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -138,6 +138,38 @@ export class GitLabAIReview {
|
|
|
138
138
|
return this.aiClient;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
/**
|
|
142
|
+
* 过滤不需要审查的文件
|
|
143
|
+
* @param {Array} changes - 变更列表
|
|
144
|
+
* @returns {Array} 过滤后的变更列表
|
|
145
|
+
*/
|
|
146
|
+
filterReviewableFiles(changes) {
|
|
147
|
+
const excludePatterns = [
|
|
148
|
+
/\.md$/i, // Markdown 文件
|
|
149
|
+
/\.txt$/i, // 文本文件
|
|
150
|
+
/\.json$/i, // JSON 配置文件
|
|
151
|
+
/\.yml$/i, // YAML 配置文件
|
|
152
|
+
/\.yaml$/i, // YAML 配置文件
|
|
153
|
+
/package-lock\.json$/i, // 依赖锁文件
|
|
154
|
+
/yarn\.lock$/i, // Yarn 锁文件
|
|
155
|
+
/pnpm-lock\.yaml$/i // PNPM 锁文件
|
|
156
|
+
];
|
|
157
|
+
|
|
158
|
+
const filtered = changes.filter(change => {
|
|
159
|
+
const fileName = change.new_path || change.old_path;
|
|
160
|
+
const shouldExclude = excludePatterns.some(pattern => pattern.test(fileName));
|
|
161
|
+
|
|
162
|
+
if (shouldExclude) {
|
|
163
|
+
console.log(`⏭️ 跳过文件: ${fileName} (不需要代码审查)`);
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return true;
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
return filtered;
|
|
171
|
+
}
|
|
172
|
+
|
|
141
173
|
/**
|
|
142
174
|
* AI 审查 MR 的所有有意义的变更并自动添加行级评论(按文件批量处理)
|
|
143
175
|
* @param {Object} options - 选项
|
|
@@ -146,11 +178,12 @@ export class GitLabAIReview {
|
|
|
146
178
|
*/
|
|
147
179
|
async reviewAndCommentOnLines(options = {}) {
|
|
148
180
|
const { maxFiles = Infinity } = options;
|
|
149
|
-
const
|
|
181
|
+
const allChanges = await this.getMergeRequestChanges();
|
|
182
|
+
const changes = this.filterReviewableFiles(allChanges);
|
|
150
183
|
const results = [];
|
|
151
184
|
|
|
152
185
|
const filesToReview = maxFiles === Infinity ? changes.length : Math.min(maxFiles, changes.length);
|
|
153
|
-
console.log(`共 ${changes.length} 个文件需要审查${maxFiles === Infinity ? '(不限制数量)' : `(最多审查 ${maxFiles} 个)`}
|
|
186
|
+
console.log(`共 ${changes.length} 个文件需要审查${maxFiles === Infinity ? '(不限制数量)' : `(最多审查 ${maxFiles} 个)`}(已过滤 ${allChanges.length - changes.length} 个文件)`);
|
|
154
187
|
|
|
155
188
|
for (const change of changes.slice(0, filesToReview)) {
|
|
156
189
|
const fileName = change.new_path || change.old_path;
|
|
@@ -280,13 +313,14 @@ export class GitLabAIReview {
|
|
|
280
313
|
enableImpactAnalysis = true
|
|
281
314
|
} = options;
|
|
282
315
|
|
|
283
|
-
const
|
|
316
|
+
const allChanges = await this.getMergeRequestChanges();
|
|
317
|
+
const changes = this.filterReviewableFiles(allChanges);
|
|
284
318
|
const mrInfo = await this.getMergeRequest();
|
|
285
319
|
const ref = mrInfo.target_branch || 'main';
|
|
286
320
|
const results = [];
|
|
287
321
|
|
|
288
322
|
const filesToReview = maxFiles === Infinity ? changes.length : Math.min(maxFiles, changes.length);
|
|
289
|
-
console.log(`共 ${changes.length} 个文件需要审查${maxFiles === Infinity ? '(不限制数量)' : `(最多审查 ${maxFiles} 个)`}
|
|
323
|
+
console.log(`共 ${changes.length} 个文件需要审查${maxFiles === Infinity ? '(不限制数量)' : `(最多审查 ${maxFiles} 个)`}(已过滤 ${allChanges.length - changes.length} 个文件)`);
|
|
290
324
|
console.log(`影响分析: ${enableImpactAnalysis ? '已启用' : '已禁用'}`);
|
|
291
325
|
|
|
292
326
|
for (const change of changes.slice(0, filesToReview)) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gitlab-ai-review",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "GitLab AI Review SDK with Impact Analysis -
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"description": "GitLab AI Review SDK with Impact Analysis - 支持影响分析、删除符号检测、文件内部冲突检查、智能文件过滤的智能代码审查工具",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|