diff --git a/__tests__/fixtures/index.ts b/__tests__/fixtures/index.ts index a926640..6c9d6bb 100644 --- a/__tests__/fixtures/index.ts +++ b/__tests__/fixtures/index.ts @@ -1,6 +1,7 @@ import { PullRequestEditedEvent, PullRequestReviewSubmittedEvent, + PullRequestReviewCommentCreatedEvent, ReleasePublishedEvent, IssuesOpenedEvent, PullRequestOpenedEvent, @@ -18,6 +19,7 @@ import _pull_request_edited_wip from './pull_request_edited_wip.json'; import _pull_request_review_4_submitted_changes_requested from './pull_request_review_4_submitted_changes_requested.json'; import _pull_request_review_submitted_approved from './pull_request_review_submitted_approved.json'; import _release_published from './release_published.json'; +import _review_comment_created from './review_comment_created.json'; export const pull_request_review_4_submitted_changes_requested = _pull_request_review_4_submitted_changes_requested as unknown as PullRequestReviewSubmittedEvent; @@ -43,4 +45,7 @@ export const pr3628_open = _pr3628_open as PullRequestOpenedEvent; export const issue_comment_created = _issue_comment_created as IssueCommentCreatedEvent; +export const review_comment_created = + _review_comment_created as PullRequestReviewCommentCreatedEvent; + export * from './generated'; diff --git a/__tests__/fixtures/review_comment_created.json b/__tests__/fixtures/review_comment_created.json new file mode 100644 index 0000000..78bf1db --- /dev/null +++ b/__tests__/fixtures/review_comment_created.json @@ -0,0 +1,623 @@ +{ + "action": "created", + "comment": { + "url": "https://api.github.com/repos/opensumi/core/pulls/comments/1766221614", + "pull_request_review_id": 2314498870, + "id": 1766221614, + "node_id": "PRRC_kwDOGZOevM5pRmcu", + "diff_hunk": "@@ -8,6 +8,8 @@ export type MaybePromise = T | Promise | PromiseLike;\n export const FRAME_ONE = 16;\n export const FRAME_TWO = FRAME_ONE * 2;\n export const FRAME_THREE = FRAME_ONE * 3;\n+export const FRAME_FOUR = FRAME_ONE * 4;\n+export const FRAME_FIVE = FRAME_ONE * 5;", + "path": "packages/utils/src/async.ts", + "commit_id": "e2a17ace8ed29a5fe0884b56aa1dce8a2311a6f5", + "original_commit_id": "e2a17ace8ed29a5fe0884b56aa1dce8a2311a6f5", + "user": { + "login": "coderabbitai[bot]", + "id": 136622811, + "node_id": "BOT_kgDOCCSy2w", + "avatar_url": "https://avatars.githubusercontent.com/in/347564?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/coderabbitai%5Bbot%5D", + "html_url": "https://github.com/apps/coderabbitai", + "followers_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/followers", + "following_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/following{/other_user}", + "gists_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/gists{/gist_id}", + "starred_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/subscriptions", + "organizations_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/orgs", + "repos_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/repos", + "events_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/events{/privacy}", + "received_events_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/received_events", + "type": "Bot", + "site_admin": false + }, + "body": "> [!TIP]\n> Codebase Verification\n\n**建议移除未使用的常量 FRAME_FOUR,保留 FRAME_FIVE。**\n\n经过验证,发现:\n\n- `FRAME_FOUR` 常量在代码库中除了定义外没有被使用。建议将其移除,以减少不必要的代码。\n- `FRAME_FIVE` 常量在 `packages/file-service/src/node/recursive/file-service-watcher.ts` 文件中被使用,用于 throttle 函数的实现。应当保留此常量。\n\n建议采取的行动:\n- 删除 `packages/utils/src/async.ts` 文件中的 `FRAME_FOUR` 常量定义。\n- 保留 `FRAME_FIVE` 常量,因为它在项目中有实际用途。\n\n\n\n
\nAnalysis chain\n\n**检查新增常量在代码库中的使用情况。**\n\n新增的 `FRAME_FOUR` 和 `FRAME_FIVE` 常量本身没有问题,但需要检查它们在代码库中是否被实际使用到。如果只是添加了常量而没有在任何地方引用,那么这些常量的存在就没有太大意义,反而会增加代码的理解难度。\n\n运行以下脚本检查常量的使用情况:\n\n\n\n如果搜索结果只有常量的定义而没有其他引用,那么建议移除这两个目前没有被使用的常量。\n\n
\n\n
\nScripts executed\n\nThe following scripts were executed for the analysis:\n\nScript:\n\n```shell\n#!/bin/bash\n# 检查 FRAME_FOUR 和 FRAME_FIVE 常量的使用情况\n\n# 在 .ts 和 .js 文件中搜索对 FRAME_FOUR 的使用\nrg --type ts --type js $'FRAME_FOUR'\n\n# 在 .ts 和 .js 文件中搜索对 FRAME_FIVE 的使用\nrg --type ts --type js $'FRAME_FIVE' \n\n```\n\nLength of output: 466\n\n
\n\n", + "created_at": "2024-09-19T06:19:07Z", + "updated_at": "2024-09-19T06:19:08Z", + "html_url": "https://github.com/opensumi/core/pull/4026#discussion_r1766221614", + "pull_request_url": "https://api.github.com/repos/opensumi/core/pulls/4026", + "author_association": "CONTRIBUTOR", + "_links": { + "self": { + "href": "https://api.github.com/repos/opensumi/core/pulls/comments/1766221614" + }, + "html": { + "href": "https://github.com/opensumi/core/pull/4026#discussion_r1766221614" + }, + "pull_request": { + "href": "https://api.github.com/repos/opensumi/core/pulls/4026" + } + }, + "reactions": { + "url": "https://api.github.com/repos/opensumi/core/pulls/comments/1766221614/reactions", + "total_count": 0, + "+1": 0, + "-1": 0, + "laugh": 0, + "hooray": 0, + "confused": 0, + "heart": 0, + "rocket": 0, + "eyes": 0 + }, + "start_line": 11, + "original_start_line": 11, + "start_side": "RIGHT", + "line": 12, + "original_line": 12, + "side": "RIGHT", + "original_position": 5, + "position": 5, + "subject_type": "line" + }, + "pull_request": { + "url": "https://api.github.com/repos/opensumi/core/pulls/4026", + "id": 2077680154, + "node_id": "PR_kwDOGZOevM571uIa", + "html_url": "https://github.com/opensumi/core/pull/4026", + "diff_url": "https://github.com/opensumi/core/pull/4026.diff", + "patch_url": "https://github.com/opensumi/core/pull/4026.patch", + "issue_url": "https://api.github.com/repos/opensumi/core/issues/4026", + "number": 4026, + "state": "open", + "locked": false, + "title": "fix: use async in watch file changes", + "user": { + "login": "bytemain", + "id": 13938334, + "node_id": "MDQ6VXNlcjEzOTM4MzM0", + "avatar_url": "https://avatars.githubusercontent.com/u/13938334?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bytemain", + "html_url": "https://github.com/bytemain", + "followers_url": "https://api.github.com/users/bytemain/followers", + "following_url": "https://api.github.com/users/bytemain/following{/other_user}", + "gists_url": "https://api.github.com/users/bytemain/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bytemain/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bytemain/subscriptions", + "organizations_url": "https://api.github.com/users/bytemain/orgs", + "repos_url": "https://api.github.com/users/bytemain/repos", + "events_url": "https://api.github.com/users/bytemain/events{/privacy}", + "received_events_url": "https://api.github.com/users/bytemain/received_events", + "type": "User", + "site_admin": false + }, + "body": "### Types\r\n\r\n- [x] 🐛 Bug Fixes\r\n\r\n\r\n### Background or solution\r\n\r\n### Changelog\r\n\n\n\n## Summary by CodeRabbit\n\n- **新功能**\n\t- 引入了 `shouldIgnorePath` 函数,用于判断路径是否应被忽略。\n- **性能改进**\n\t- 文件路径解析方法现支持异步处理,提升了文件操作的性能和响应性。\n\t- 文件系统操作已转换为异步,增强了文件监视器的响应能力。\n- **代码重构**\n\t- 简化了临时文件检测逻辑,改用新导入的 `shouldIgnorePath` 函数。\n\t- 改进了文件更改事件的处理逻辑,确保只传播相关更改。\n- **测试改进**\n\t- 测试用例中引入了 `Deferred` 对象,以更有效地管理异步操作。\n", + "created_at": "2024-09-18T02:51:04Z", + "updated_at": "2024-09-19T06:19:08Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "568d7b07ebbb02a0bd5f90ac6bcac17dbfafc570", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [ + { + "id": 3558679522, + "node_id": "LA_kwDOGZOevM7UHSPi", + "url": "https://api.github.com/repos/opensumi/core/labels/%F0%9F%90%9E%20bug", + "name": "🐞 bug", + "color": "d73a4a", + "default": false, + "description": "Something isn't working" + } + ], + "milestone": null, + "draft": false, + "commits_url": "https://api.github.com/repos/opensumi/core/pulls/4026/commits", + "review_comments_url": "https://api.github.com/repos/opensumi/core/pulls/4026/comments", + "review_comment_url": "https://api.github.com/repos/opensumi/core/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/opensumi/core/issues/4026/comments", + "statuses_url": "https://api.github.com/repos/opensumi/core/statuses/e2a17ace8ed29a5fe0884b56aa1dce8a2311a6f5", + "head": { + "label": "opensumi:fix/use-async", + "ref": "fix/use-async", + "sha": "e2a17ace8ed29a5fe0884b56aa1dce8a2311a6f5", + "user": { + "login": "opensumi", + "id": 90233428, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjkwMjMzNDI4", + "avatar_url": "https://avatars.githubusercontent.com/u/90233428?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/opensumi", + "html_url": "https://github.com/opensumi", + "followers_url": "https://api.github.com/users/opensumi/followers", + "following_url": "https://api.github.com/users/opensumi/following{/other_user}", + "gists_url": "https://api.github.com/users/opensumi/gists{/gist_id}", + "starred_url": "https://api.github.com/users/opensumi/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/opensumi/subscriptions", + "organizations_url": "https://api.github.com/users/opensumi/orgs", + "repos_url": "https://api.github.com/users/opensumi/repos", + "events_url": "https://api.github.com/users/opensumi/events{/privacy}", + "received_events_url": "https://api.github.com/users/opensumi/received_events", + "type": "Organization", + "site_admin": false + }, + "repo": { + "id": 429104828, + "node_id": "R_kgDOGZOevA", + "name": "core", + "full_name": "opensumi/core", + "private": false, + "owner": { + "login": "opensumi", + "id": 90233428, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjkwMjMzNDI4", + "avatar_url": "https://avatars.githubusercontent.com/u/90233428?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/opensumi", + "html_url": "https://github.com/opensumi", + "followers_url": "https://api.github.com/users/opensumi/followers", + "following_url": "https://api.github.com/users/opensumi/following{/other_user}", + "gists_url": "https://api.github.com/users/opensumi/gists{/gist_id}", + "starred_url": "https://api.github.com/users/opensumi/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/opensumi/subscriptions", + "organizations_url": "https://api.github.com/users/opensumi/orgs", + "repos_url": "https://api.github.com/users/opensumi/repos", + "events_url": "https://api.github.com/users/opensumi/events{/privacy}", + "received_events_url": "https://api.github.com/users/opensumi/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/opensumi/core", + "description": "🚀 A framework helps you quickly build AI Native IDE products. https://preview.opensumi.com", + "fork": false, + "url": "https://api.github.com/repos/opensumi/core", + "forks_url": "https://api.github.com/repos/opensumi/core/forks", + "keys_url": "https://api.github.com/repos/opensumi/core/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/opensumi/core/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/opensumi/core/teams", + "hooks_url": "https://api.github.com/repos/opensumi/core/hooks", + "issue_events_url": "https://api.github.com/repos/opensumi/core/issues/events{/number}", + "events_url": "https://api.github.com/repos/opensumi/core/events", + "assignees_url": "https://api.github.com/repos/opensumi/core/assignees{/user}", + "branches_url": "https://api.github.com/repos/opensumi/core/branches{/branch}", + "tags_url": "https://api.github.com/repos/opensumi/core/tags", + "blobs_url": "https://api.github.com/repos/opensumi/core/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/opensumi/core/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/opensumi/core/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/opensumi/core/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/opensumi/core/statuses/{sha}", + "languages_url": "https://api.github.com/repos/opensumi/core/languages", + "stargazers_url": "https://api.github.com/repos/opensumi/core/stargazers", + "contributors_url": "https://api.github.com/repos/opensumi/core/contributors", + "subscribers_url": "https://api.github.com/repos/opensumi/core/subscribers", + "subscription_url": "https://api.github.com/repos/opensumi/core/subscription", + "commits_url": "https://api.github.com/repos/opensumi/core/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/opensumi/core/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/opensumi/core/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/opensumi/core/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/opensumi/core/contents/{+path}", + "compare_url": "https://api.github.com/repos/opensumi/core/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/opensumi/core/merges", + "archive_url": "https://api.github.com/repos/opensumi/core/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/opensumi/core/downloads", + "issues_url": "https://api.github.com/repos/opensumi/core/issues{/number}", + "pulls_url": "https://api.github.com/repos/opensumi/core/pulls{/number}", + "milestones_url": "https://api.github.com/repos/opensumi/core/milestones{/number}", + "notifications_url": "https://api.github.com/repos/opensumi/core/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/opensumi/core/labels{/name}", + "releases_url": "https://api.github.com/repos/opensumi/core/releases{/id}", + "deployments_url": "https://api.github.com/repos/opensumi/core/deployments", + "created_at": "2021-11-17T15:42:48Z", + "updated_at": "2024-09-19T03:27:34Z", + "pushed_at": "2024-09-19T06:14:19Z", + "git_url": "git://github.com/opensumi/core.git", + "ssh_url": "git@github.com:opensumi/core.git", + "clone_url": "https://github.com/opensumi/core.git", + "svn_url": "https://github.com/opensumi/core", + "homepage": "https://opensumi.com", + "size": 157920, + "stargazers_count": 2843, + "watchers_count": 2843, + "language": "TypeScript", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "has_discussions": true, + "forks_count": 369, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 180, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + "ai", + "ai-first", + "ai-native", + "editor", + "electron", + "ide", + "ide-framework", + "opensumi", + "typescript", + "webide" + ], + "visibility": "public", + "forks": 369, + "open_issues": 180, + "watchers": 2843, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": false, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": true, + "allow_update_branch": true, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "base": { + "label": "opensumi:main", + "ref": "main", + "sha": "36491e3b533f44cc1b969f2f87e299d2a7c6b2ec", + "user": { + "login": "opensumi", + "id": 90233428, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjkwMjMzNDI4", + "avatar_url": "https://avatars.githubusercontent.com/u/90233428?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/opensumi", + "html_url": "https://github.com/opensumi", + "followers_url": "https://api.github.com/users/opensumi/followers", + "following_url": "https://api.github.com/users/opensumi/following{/other_user}", + "gists_url": "https://api.github.com/users/opensumi/gists{/gist_id}", + "starred_url": "https://api.github.com/users/opensumi/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/opensumi/subscriptions", + "organizations_url": "https://api.github.com/users/opensumi/orgs", + "repos_url": "https://api.github.com/users/opensumi/repos", + "events_url": "https://api.github.com/users/opensumi/events{/privacy}", + "received_events_url": "https://api.github.com/users/opensumi/received_events", + "type": "Organization", + "site_admin": false + }, + "repo": { + "id": 429104828, + "node_id": "R_kgDOGZOevA", + "name": "core", + "full_name": "opensumi/core", + "private": false, + "owner": { + "login": "opensumi", + "id": 90233428, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjkwMjMzNDI4", + "avatar_url": "https://avatars.githubusercontent.com/u/90233428?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/opensumi", + "html_url": "https://github.com/opensumi", + "followers_url": "https://api.github.com/users/opensumi/followers", + "following_url": "https://api.github.com/users/opensumi/following{/other_user}", + "gists_url": "https://api.github.com/users/opensumi/gists{/gist_id}", + "starred_url": "https://api.github.com/users/opensumi/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/opensumi/subscriptions", + "organizations_url": "https://api.github.com/users/opensumi/orgs", + "repos_url": "https://api.github.com/users/opensumi/repos", + "events_url": "https://api.github.com/users/opensumi/events{/privacy}", + "received_events_url": "https://api.github.com/users/opensumi/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/opensumi/core", + "description": "🚀 A framework helps you quickly build AI Native IDE products. https://preview.opensumi.com", + "fork": false, + "url": "https://api.github.com/repos/opensumi/core", + "forks_url": "https://api.github.com/repos/opensumi/core/forks", + "keys_url": "https://api.github.com/repos/opensumi/core/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/opensumi/core/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/opensumi/core/teams", + "hooks_url": "https://api.github.com/repos/opensumi/core/hooks", + "issue_events_url": "https://api.github.com/repos/opensumi/core/issues/events{/number}", + "events_url": "https://api.github.com/repos/opensumi/core/events", + "assignees_url": "https://api.github.com/repos/opensumi/core/assignees{/user}", + "branches_url": "https://api.github.com/repos/opensumi/core/branches{/branch}", + "tags_url": "https://api.github.com/repos/opensumi/core/tags", + "blobs_url": "https://api.github.com/repos/opensumi/core/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/opensumi/core/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/opensumi/core/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/opensumi/core/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/opensumi/core/statuses/{sha}", + "languages_url": "https://api.github.com/repos/opensumi/core/languages", + "stargazers_url": "https://api.github.com/repos/opensumi/core/stargazers", + "contributors_url": "https://api.github.com/repos/opensumi/core/contributors", + "subscribers_url": "https://api.github.com/repos/opensumi/core/subscribers", + "subscription_url": "https://api.github.com/repos/opensumi/core/subscription", + "commits_url": "https://api.github.com/repos/opensumi/core/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/opensumi/core/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/opensumi/core/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/opensumi/core/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/opensumi/core/contents/{+path}", + "compare_url": "https://api.github.com/repos/opensumi/core/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/opensumi/core/merges", + "archive_url": "https://api.github.com/repos/opensumi/core/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/opensumi/core/downloads", + "issues_url": "https://api.github.com/repos/opensumi/core/issues{/number}", + "pulls_url": "https://api.github.com/repos/opensumi/core/pulls{/number}", + "milestones_url": "https://api.github.com/repos/opensumi/core/milestones{/number}", + "notifications_url": "https://api.github.com/repos/opensumi/core/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/opensumi/core/labels{/name}", + "releases_url": "https://api.github.com/repos/opensumi/core/releases{/id}", + "deployments_url": "https://api.github.com/repos/opensumi/core/deployments", + "created_at": "2021-11-17T15:42:48Z", + "updated_at": "2024-09-19T03:27:34Z", + "pushed_at": "2024-09-19T06:14:19Z", + "git_url": "git://github.com/opensumi/core.git", + "ssh_url": "git@github.com:opensumi/core.git", + "clone_url": "https://github.com/opensumi/core.git", + "svn_url": "https://github.com/opensumi/core", + "homepage": "https://opensumi.com", + "size": 157920, + "stargazers_count": 2843, + "watchers_count": 2843, + "language": "TypeScript", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "has_discussions": true, + "forks_count": 369, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 180, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + "ai", + "ai-first", + "ai-native", + "editor", + "electron", + "ide", + "ide-framework", + "opensumi", + "typescript", + "webide" + ], + "visibility": "public", + "forks": 369, + "open_issues": 180, + "watchers": 2843, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": false, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": true, + "allow_update_branch": true, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/opensumi/core/pulls/4026" + }, + "html": { + "href": "https://github.com/opensumi/core/pull/4026" + }, + "issue": { + "href": "https://api.github.com/repos/opensumi/core/issues/4026" + }, + "comments": { + "href": "https://api.github.com/repos/opensumi/core/issues/4026/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/opensumi/core/pulls/4026/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/opensumi/core/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/opensumi/core/pulls/4026/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/opensumi/core/statuses/e2a17ace8ed29a5fe0884b56aa1dce8a2311a6f5" + } + }, + "author_association": "MEMBER", + "auto_merge": null, + "active_lock_reason": null + }, + "repository": { + "id": 429104828, + "node_id": "R_kgDOGZOevA", + "name": "core", + "full_name": "opensumi/core", + "private": false, + "owner": { + "login": "opensumi", + "id": 90233428, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjkwMjMzNDI4", + "avatar_url": "https://avatars.githubusercontent.com/u/90233428?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/opensumi", + "html_url": "https://github.com/opensumi", + "followers_url": "https://api.github.com/users/opensumi/followers", + "following_url": "https://api.github.com/users/opensumi/following{/other_user}", + "gists_url": "https://api.github.com/users/opensumi/gists{/gist_id}", + "starred_url": "https://api.github.com/users/opensumi/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/opensumi/subscriptions", + "organizations_url": "https://api.github.com/users/opensumi/orgs", + "repos_url": "https://api.github.com/users/opensumi/repos", + "events_url": "https://api.github.com/users/opensumi/events{/privacy}", + "received_events_url": "https://api.github.com/users/opensumi/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/opensumi/core", + "description": "🚀 A framework helps you quickly build AI Native IDE products. https://preview.opensumi.com", + "fork": false, + "url": "https://api.github.com/repos/opensumi/core", + "forks_url": "https://api.github.com/repos/opensumi/core/forks", + "keys_url": "https://api.github.com/repos/opensumi/core/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/opensumi/core/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/opensumi/core/teams", + "hooks_url": "https://api.github.com/repos/opensumi/core/hooks", + "issue_events_url": "https://api.github.com/repos/opensumi/core/issues/events{/number}", + "events_url": "https://api.github.com/repos/opensumi/core/events", + "assignees_url": "https://api.github.com/repos/opensumi/core/assignees{/user}", + "branches_url": "https://api.github.com/repos/opensumi/core/branches{/branch}", + "tags_url": "https://api.github.com/repos/opensumi/core/tags", + "blobs_url": "https://api.github.com/repos/opensumi/core/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/opensumi/core/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/opensumi/core/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/opensumi/core/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/opensumi/core/statuses/{sha}", + "languages_url": "https://api.github.com/repos/opensumi/core/languages", + "stargazers_url": "https://api.github.com/repos/opensumi/core/stargazers", + "contributors_url": "https://api.github.com/repos/opensumi/core/contributors", + "subscribers_url": "https://api.github.com/repos/opensumi/core/subscribers", + "subscription_url": "https://api.github.com/repos/opensumi/core/subscription", + "commits_url": "https://api.github.com/repos/opensumi/core/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/opensumi/core/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/opensumi/core/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/opensumi/core/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/opensumi/core/contents/{+path}", + "compare_url": "https://api.github.com/repos/opensumi/core/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/opensumi/core/merges", + "archive_url": "https://api.github.com/repos/opensumi/core/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/opensumi/core/downloads", + "issues_url": "https://api.github.com/repos/opensumi/core/issues{/number}", + "pulls_url": "https://api.github.com/repos/opensumi/core/pulls{/number}", + "milestones_url": "https://api.github.com/repos/opensumi/core/milestones{/number}", + "notifications_url": "https://api.github.com/repos/opensumi/core/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/opensumi/core/labels{/name}", + "releases_url": "https://api.github.com/repos/opensumi/core/releases{/id}", + "deployments_url": "https://api.github.com/repos/opensumi/core/deployments", + "created_at": "2021-11-17T15:42:48Z", + "updated_at": "2024-09-19T03:27:34Z", + "pushed_at": "2024-09-19T06:14:19Z", + "git_url": "git://github.com/opensumi/core.git", + "ssh_url": "git@github.com:opensumi/core.git", + "clone_url": "https://github.com/opensumi/core.git", + "svn_url": "https://github.com/opensumi/core", + "homepage": "https://opensumi.com", + "size": 157920, + "stargazers_count": 2843, + "watchers_count": 2843, + "language": "TypeScript", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "has_discussions": true, + "forks_count": 369, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 180, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + "ai", + "ai-first", + "ai-native", + "editor", + "electron", + "ide", + "ide-framework", + "opensumi", + "typescript", + "webide" + ], + "visibility": "public", + "forks": 369, + "open_issues": 180, + "watchers": 2843, + "default_branch": "main", + "custom_properties": {} + }, + "organization": { + "login": "opensumi", + "id": 90233428, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjkwMjMzNDI4", + "url": "https://api.github.com/orgs/opensumi", + "repos_url": "https://api.github.com/orgs/opensumi/repos", + "events_url": "https://api.github.com/orgs/opensumi/events", + "hooks_url": "https://api.github.com/orgs/opensumi/hooks", + "issues_url": "https://api.github.com/orgs/opensumi/issues", + "members_url": "https://api.github.com/orgs/opensumi/members{/member}", + "public_members_url": "https://api.github.com/orgs/opensumi/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/90233428?v=4", + "description": "A framework helps you quickly build IDE products." + }, + "sender": { + "login": "coderabbitai[bot]", + "id": 136622811, + "node_id": "BOT_kgDOCCSy2w", + "avatar_url": "https://avatars.githubusercontent.com/in/347564?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/coderabbitai%5Bbot%5D", + "html_url": "https://github.com/apps/coderabbitai", + "followers_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/followers", + "following_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/following{/other_user}", + "gists_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/gists{/gist_id}", + "starred_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/subscriptions", + "organizations_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/orgs", + "repos_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/repos", + "events_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/events{/privacy}", + "received_events_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/received_events", + "type": "Bot", + "site_admin": false + }, + "installation": { + "id": 23059464, + "node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uMjMwNTk0NjQ=" + } +} diff --git a/__tests__/github/templates/__snapshots__/review.test.ts.snap b/__tests__/github/templates/__snapshots__/review.test.ts.snap index 2713069..51680ef 100644 --- a/__tests__/github/templates/__snapshots__/review.test.ts.snap +++ b/__tests__/github/templates/__snapshots__/review.test.ts.snap @@ -1,5 +1,131 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`github templates pr review can handle complex code review 1`] = ` +{ + "compactText": "[coderabbitai\\[bot\\]](https://github.com/apps/coderabbitai) created [review comment](https://github.com/opensumi/core/pull/4026#discussion_r1766221614): + +> [!TIP] +> Codebase Verification + +**建议移除未使用的常量 FRAME_FOUR,保留 FRAME_FIVE。** + +经过验证,发现: + +- \`FRAME_FOUR\` 常量在代码库中除了定义外没有被使用。建议将其移除,以减少不必要的代码。 +- \`FRAME_FIVE\` 常量在 \`packages/file-service/src/node/recursive/file-service-watcher.ts\` 文件中被使用,用于 throttle 函数的实现。应当保留此常量。 + +建议采取的行动: +- 删除 \`packages/utils/src/async.ts\` 文件中的 \`FRAME_FOUR\` 常量定义。 +- 保留 \`FRAME_FIVE\` 常量,因为它在项目中有实际用途。 + + + +
+Analysis chain + +**检查新增常量在代码库中的使用情况。** + +新增的 \`FRAME_FOUR\` 和 \`FRAME_FIVE\` 常量本身没有问题,但需要检查它们在代码库中是否被实际使用到。如果只是添加了常量而没有在任何地方引用,那么这些常量的存在就没有太大意义,反而会增加代码的理解难度。 + +运行以下脚本检查常量的使用情况: + + + +如果搜索结果只有常量的定义而没有其他引用,那么建议移除这两个目前没有被使用的常量。 + +
+ +
+Scripts executed + +The following scripts were executed for the analysis: + +Script: + +\`\`\`shell +#!/bin/bash +# 检查 FRAME_FOUR 和 FRAME_FIVE 常量的使用情况 + +# 在 .ts 和 .js 文件中搜索对 FRAME_FOUR 的使用 +rg --type ts --type js $'FRAME_FOUR' + +# 在 .ts 和 .js 文件中搜索对 FRAME_FIVE 的使用 +rg --type ts --type js $'FRAME_FIVE' + +\`\`\` + +Length of output: 466 + +
+ + +", + "text": "#### [coderabbitai\\[bot\\]](https://github.com/apps/coderabbitai) created [review comment](https://github.com/opensumi/core/pull/4026#discussion_r1766221614) on [pull request](https://github.com/opensumi/core/pull/4026) + +#### [#4026 fix: use async in watch file changes](https://github.com/opensumi/core/pull/4026) + +*** + +> [!TIP] +> Codebase Verification + +**建议移除未使用的常量 FRAME_FOUR,保留 FRAME_FIVE。** + +经过验证,发现: + +- \`FRAME_FOUR\` 常量在代码库中除了定义外没有被使用。建议将其移除,以减少不必要的代码。 +- \`FRAME_FIVE\` 常量在 \`packages/file-service/src/node/recursive/file-service-watcher.ts\` 文件中被使用,用于 throttle 函数的实现。应当保留此常量。 + +建议采取的行动: +- 删除 \`packages/utils/src/async.ts\` 文件中的 \`FRAME_FOUR\` 常量定义。 +- 保留 \`FRAME_FIVE\` 常量,因为它在项目中有实际用途。 + + + +
+Analysis chain + +**检查新增常量在代码库中的使用情况。** + +新增的 \`FRAME_FOUR\` 和 \`FRAME_FIVE\` 常量本身没有问题,但需要检查它们在代码库中是否被实际使用到。如果只是添加了常量而没有在任何地方引用,那么这些常量的存在就没有太大意义,反而会增加代码的理解难度。 + +运行以下脚本检查常量的使用情况: + + + +如果搜索结果只有常量的定义而没有其他引用,那么建议移除这两个目前没有被使用的常量。 + +
+ +
+Scripts executed + +The following scripts were executed for the analysis: + +Script: + +\`\`\`shell +#!/bin/bash +# 检查 FRAME_FOUR 和 FRAME_FIVE 常量的使用情况 + +# 在 .ts 和 .js 文件中搜索对 FRAME_FOUR 的使用 +rg --type ts --type js $'FRAME_FOUR' + +# 在 .ts 和 .js 文件中搜索对 FRAME_FIVE 的使用 +rg --type ts --type js $'FRAME_FIVE' + +\`\`\` + +Length of output: 466 + +
+ + +", + "title": "Review comment created", +} +`; + exports[`github templates pr review can handle pull_request_review_2_1_dismissed_dismissed 1`] = ` { "compactText": undefined, diff --git a/__tests__/github/templates/review.test.ts b/__tests__/github/templates/review.test.ts index 8235c31..b54f3e7 100644 --- a/__tests__/github/templates/review.test.ts +++ b/__tests__/github/templates/review.test.ts @@ -4,6 +4,7 @@ import { handleReview } from '@/github/templates/review'; import { pull_request_2_review_comment_0_created, pull_request_review_2_1_dismissed_dismissed, + review_comment_created, } from '../../fixtures'; import { ctx } from '../ctx'; @@ -16,6 +17,11 @@ describe('github templates pr review', () => { console.log(`pull_request_review_comment_0_created ~ result`, result); expect(result).toMatchSnapshot(); }); + it('can handle complex code review', async () => { + const result = await handleReviewComment(review_comment_created, ctx); + console.log(`review_comment_created ~ result`, result); + expect(result).toMatchSnapshot(); + }); it('can handle pull_request_review_2_1_dismissed_dismissed', async () => { const result = await handleReview( pull_request_review_2_1_dismissed_dismissed,