job51-gitlab-cr-node-jt-1 3.0.0 → 3.0.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/index.js +26 -6
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -144,7 +144,22 @@ class GitLabCodeReviewer {
|
|
|
144
144
|
const blockStartTime = Date.now();
|
|
145
145
|
const blockIdentifier = `${diffObject.new_path || diffObject.old_path}#large-file`;
|
|
146
146
|
const review_result = await this.reviewDiffWithClaudeUsingFile(tmpFileName, blockIdentifier, true);
|
|
147
|
-
|
|
147
|
+
|
|
148
|
+
// 对于大文件,设置完整的行号范围信息(使用文件总行数)
|
|
149
|
+
const fileLineCount = fileContent.split('\n').length;
|
|
150
|
+
const blockObj = {
|
|
151
|
+
...diffObject,
|
|
152
|
+
review_result,
|
|
153
|
+
temp_file_path: tmpFileName,
|
|
154
|
+
is_large_file: true,
|
|
155
|
+
// 设置行号范围信息,让行级评论验证能够通过
|
|
156
|
+
line_info: {
|
|
157
|
+
old_start: diffObject.new_file ? 0 : 1,
|
|
158
|
+
old_count: diffObject.new_file ? 0 : fileLineCount,
|
|
159
|
+
new_start: 1,
|
|
160
|
+
new_count: fileLineCount
|
|
161
|
+
}
|
|
162
|
+
};
|
|
148
163
|
|
|
149
164
|
// 记录审查指标
|
|
150
165
|
const reviewTime = Date.now() - blockStartTime;
|
|
@@ -156,11 +171,16 @@ class GitLabCodeReviewer {
|
|
|
156
171
|
|
|
157
172
|
// 检查审查结果中是否包含严重问题
|
|
158
173
|
if (blockObj.review_result && blockObj.review_result.reportContent && blockObj.review_result.reportContent.includes('严重问题')) {
|
|
159
|
-
//
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
174
|
+
// 尝试发布行级评论(大文件现在也有 line_info,可以验证行号)
|
|
175
|
+
const commentResult = await this.postSingleCommentToGitLab(projectId, mergeRequestIid, {
|
|
176
|
+
diff_info: blockObj,
|
|
177
|
+
block_index: blockIndex,
|
|
178
|
+
review_result: blockObj.review_result,
|
|
179
|
+
});
|
|
180
|
+
if (commentResult && commentResult.hallucination_detected) {
|
|
181
|
+
hallucinationDetected = true;
|
|
182
|
+
}
|
|
183
|
+
debugLog(`大文件审查结果已尝试发布行级评论: ${diffObject.new_path || diffObject.old_path}`);
|
|
164
184
|
} else {
|
|
165
185
|
debugLog(`大文件审查未发现严重问题: ${diffObject.new_path || diffObject.old_path}`);
|
|
166
186
|
}
|