scai 0.1.77 → 0.1.78
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 -1
- package/dist/github/github.js +30 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -139,7 +139,7 @@ SCAI supports an integrated review flow for GitHub pull requests. To get started
|
|
|
139
139
|
scai git review
|
|
140
140
|
```
|
|
141
141
|
|
|
142
|
-
Use `-a` to list all PRs that require
|
|
142
|
+
Use `-a` to list all PRs that require a review:
|
|
143
143
|
|
|
144
144
|
```sh
|
|
145
145
|
scai git review -a
|
package/dist/github/github.js
CHANGED
|
@@ -61,11 +61,40 @@ export async function submitReview(prNumber, body, event, comments) {
|
|
|
61
61
|
body: JSON.stringify({
|
|
62
62
|
body,
|
|
63
63
|
event,
|
|
64
|
-
comments
|
|
64
|
+
comments,
|
|
65
65
|
}),
|
|
66
66
|
});
|
|
67
67
|
if (!res.ok) {
|
|
68
68
|
const errorText = await res.text();
|
|
69
|
+
// Attempt to parse error body
|
|
70
|
+
let parsed = {};
|
|
71
|
+
try {
|
|
72
|
+
parsed = JSON.parse(errorText);
|
|
73
|
+
}
|
|
74
|
+
catch (_) {
|
|
75
|
+
// leave as raw text if parsing fails
|
|
76
|
+
}
|
|
77
|
+
const knownErrors = Array.isArray(parsed.errors) ? parsed.errors.join('; ') : '';
|
|
78
|
+
// Handle known error cases
|
|
79
|
+
if (res.status === 422) {
|
|
80
|
+
if (knownErrors.includes('Can not approve your own pull request')) {
|
|
81
|
+
console.warn(`⚠️ Skipping approval: You cannot approve your own pull request.`);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (knownErrors.includes('Comments may only be specified on pull requests with a diff')) {
|
|
85
|
+
console.warn(`⚠️ Cannot post comments: PR has no diff.`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (knownErrors.includes('path is missing') || knownErrors.includes('line is missing')) {
|
|
89
|
+
console.warn(`⚠️ Some inline comments are missing a path or line number. Skipping review.`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (knownErrors.includes('Position is invalid') || knownErrors.includes('line must be part of the diff')) {
|
|
93
|
+
console.warn(`⚠️ One or more comment positions are invalid — probably outside the diff. Skipping review.`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Unknown error
|
|
69
98
|
throw new Error(`Failed to submit review: ${res.status} ${res.statusText} - ${errorText}`);
|
|
70
99
|
}
|
|
71
100
|
console.log(`✅ Submitted ${event} review for PR #${prNumber}`);
|