@spaceflow/core 0.16.0 → 0.18.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/dist/index.js +40 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/shared/git-provider/adapters/gitea.adapter.spec.ts +2 -2
- package/src/shared/git-provider/adapters/gitea.adapter.ts +38 -3
- package/src/shared/git-provider/adapters/github.adapter.ts +4 -2
- package/src/shared/git-provider/types.ts +2 -0
package/package.json
CHANGED
|
@@ -383,11 +383,11 @@ describe("GiteaAdapter", () => {
|
|
|
383
383
|
});
|
|
384
384
|
|
|
385
385
|
describe("listPullReviews", () => {
|
|
386
|
-
it("应请求正确的 URL", async () => {
|
|
386
|
+
it("应请求正确的 URL(带分页参数)", async () => {
|
|
387
387
|
fetchSpy.mockResolvedValue(mockResponse([]));
|
|
388
388
|
await adapter.listPullReviews("owner", "repo", 42);
|
|
389
389
|
expect(fetchSpy).toHaveBeenCalledWith(
|
|
390
|
-
"https://gitea.example.com/api/v1/repos/owner/repo/pulls/42/reviews",
|
|
390
|
+
"https://gitea.example.com/api/v1/repos/owner/repo/pulls/42/reviews?page=1&limit=50",
|
|
391
391
|
expect.anything(),
|
|
392
392
|
);
|
|
393
393
|
});
|
|
@@ -438,7 +438,20 @@ export class GiteaAdapter implements GitProvider {
|
|
|
438
438
|
}
|
|
439
439
|
|
|
440
440
|
async listPullReviews(owner: string, repo: string, index: number): Promise<PullReview[]> {
|
|
441
|
-
|
|
441
|
+
const allReviews: PullReview[] = [];
|
|
442
|
+
let page = 1;
|
|
443
|
+
const limit = 50;
|
|
444
|
+
while (true) {
|
|
445
|
+
const reviews = await this.request<PullReview[]>(
|
|
446
|
+
"GET",
|
|
447
|
+
`/repos/${owner}/${repo}/pulls/${index}/reviews?page=${page}&limit=${limit}`,
|
|
448
|
+
);
|
|
449
|
+
if (!reviews || reviews.length === 0) break;
|
|
450
|
+
allReviews.push(...reviews);
|
|
451
|
+
if (reviews.length < limit) break;
|
|
452
|
+
page++;
|
|
453
|
+
}
|
|
454
|
+
return allReviews;
|
|
442
455
|
}
|
|
443
456
|
|
|
444
457
|
async updatePullReview(
|
|
@@ -484,8 +497,30 @@ export class GiteaAdapter implements GitProvider {
|
|
|
484
497
|
await this.request<void>("DELETE", `/repos/${owner}/${repo}/pulls/comments/${commentId}`);
|
|
485
498
|
}
|
|
486
499
|
|
|
487
|
-
async listResolvedThreads(): Promise<ResolvedThread[]> {
|
|
488
|
-
|
|
500
|
+
async listResolvedThreads(owner: string, repo: string, index: number): Promise<ResolvedThread[]> {
|
|
501
|
+
const result: ResolvedThread[] = [];
|
|
502
|
+
try {
|
|
503
|
+
const reviews = await this.listPullReviews(owner, repo, index);
|
|
504
|
+
for (const review of reviews) {
|
|
505
|
+
if (!review.id) continue;
|
|
506
|
+
const comments = await this.listPullReviewComments(owner, repo, index, review.id);
|
|
507
|
+
for (const comment of comments) {
|
|
508
|
+
if (!comment.resolver) continue;
|
|
509
|
+
result.push({
|
|
510
|
+
path: comment.path,
|
|
511
|
+
line: comment.position,
|
|
512
|
+
resolvedBy: {
|
|
513
|
+
id: comment.resolver.id,
|
|
514
|
+
login: comment.resolver.login,
|
|
515
|
+
},
|
|
516
|
+
body: comment.body,
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
} catch {
|
|
521
|
+
// 获取失败时返回空数组,不影响主流程
|
|
522
|
+
}
|
|
523
|
+
return result;
|
|
489
524
|
}
|
|
490
525
|
|
|
491
526
|
// ============ Reaction 操作 ============
|
|
@@ -37,7 +37,7 @@ interface GraphQLReviewThread {
|
|
|
37
37
|
resolvedBy?: { login: string; databaseId: number } | null;
|
|
38
38
|
path?: string | null;
|
|
39
39
|
line?: number | null;
|
|
40
|
-
comments: { nodes: Array<{ databaseId: number }> };
|
|
40
|
+
comments: { nodes: Array<{ databaseId: number; body?: string }> };
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -838,12 +838,14 @@ export class GithubAdapter implements GitProvider {
|
|
|
838
838
|
const result: ResolvedThread[] = [];
|
|
839
839
|
for (const thread of threads) {
|
|
840
840
|
if (!thread.isResolved) continue;
|
|
841
|
+
const firstComment = thread.comments.nodes[0];
|
|
841
842
|
result.push({
|
|
842
843
|
path: thread.path ?? undefined,
|
|
843
844
|
line: thread.line ?? undefined,
|
|
844
845
|
resolvedBy: thread.resolvedBy
|
|
845
846
|
? { id: thread.resolvedBy.databaseId, login: thread.resolvedBy.login }
|
|
846
847
|
: null,
|
|
848
|
+
body: firstComment?.body,
|
|
847
849
|
});
|
|
848
850
|
}
|
|
849
851
|
return result;
|
|
@@ -868,7 +870,7 @@ export class GithubAdapter implements GitProvider {
|
|
|
868
870
|
path
|
|
869
871
|
line
|
|
870
872
|
comments(first: 1) {
|
|
871
|
-
nodes { databaseId }
|
|
873
|
+
nodes { databaseId body }
|
|
872
874
|
}
|
|
873
875
|
}
|
|
874
876
|
}
|