From f49a23a387e793008973e5af68b1ade627a51dad Mon Sep 17 00:00:00 2001 From: backwardspy Date: Tue, 24 Sep 2024 20:24:02 +0100 Subject: [PATCH] feat: ignore requested reviews on userstyles (#31) there is no way i can see to detect if a review was requested automatically as part of a codeowners configuration, so we just ignore all reviews requested on the userstyles repo instead. --- fixtures/pull_request/multiple_reviewers.json | 4 +- fixtures/pull_request/userstyles_review.json | 586 ++++++++++++++++++ .../pull_request/multiple_reviewers.snap | 4 +- src/embed_builder.rs | 2 +- src/events/pull_request.rs | 22 +- 5 files changed, 611 insertions(+), 7 deletions(-) create mode 100644 fixtures/pull_request/userstyles_review.json diff --git a/fixtures/pull_request/multiple_reviewers.json b/fixtures/pull_request/multiple_reviewers.json index 573a7e5..aa2ea14 100644 --- a/fixtures/pull_request/multiple_reviewers.json +++ b/fixtures/pull_request/multiple_reviewers.json @@ -443,8 +443,8 @@ "repository": { "id": 606608861, "node_id": "R_kgDOJCgd3Q", - "name": "userstyles", - "full_name": "catppuccin/userstyles", + "name": "not-userstyles", + "full_name": "catppuccin/not-userstyles", "private": false, "owner": { "login": "catppuccin", diff --git a/fixtures/pull_request/userstyles_review.json b/fixtures/pull_request/userstyles_review.json new file mode 100644 index 0000000..a4ec128 --- /dev/null +++ b/fixtures/pull_request/userstyles_review.json @@ -0,0 +1,586 @@ +{ + "action": "review_requested", + "number": 1338, + "pull_request": { + "url": "https://api.github.com/repos/catppuccin/userstyles/pulls/1338", + "id": 2089568580, + "node_id": "PR_kwDOJCgd3c58jElE", + "html_url": "https://github.com/catppuccin/userstyles/pull/1338", + "diff_url": "https://github.com/catppuccin/userstyles/pull/1338.diff", + "patch_url": "https://github.com/catppuccin/userstyles/pull/1338.patch", + "issue_url": "https://api.github.com/repos/catppuccin/userstyles/issues/1338", + "number": 1338, + "state": "open", + "locked": false, + "title": "fix(lastfm): last.month/info banner", + "user": { + "login": "somerand0mcatt", + "id": 180954465, + "node_id": "U_kgDOCsklYQ", + "avatar_url": "https://avatars.githubusercontent.com/u/180954465?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/somerand0mcatt", + "html_url": "https://github.com/somerand0mcatt", + "followers_url": "https://api.github.com/users/somerand0mcatt/followers", + "following_url": "https://api.github.com/users/somerand0mcatt/following{/other_user}", + "gists_url": "https://api.github.com/users/somerand0mcatt/gists{/gist_id}", + "starred_url": "https://api.github.com/users/somerand0mcatt/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/somerand0mcatt/subscriptions", + "organizations_url": "https://api.github.com/users/somerand0mcatt/orgs", + "repos_url": "https://api.github.com/users/somerand0mcatt/repos", + "events_url": "https://api.github.com/users/somerand0mcatt/events{/privacy}", + "received_events_url": "https://api.github.com/users/somerand0mcatt/received_events", + "type": "User", + "site_admin": false + }, + "body": "## 🔧 What does this fix? 🔧\r\ncloses #1330 :)\r\n\r\n## 🗒 Checklist 🗒\r\n\r\n- [X] I have read and followed Catppuccin's [contributing guidelines](https://github.com/catppuccin/userstyles/blob/main/docs/CONTRIBUTING.md).\r\n- [X] I have updated the version appropriately in the `==UserStyle==` header of the `catppuccin.user.css` file.\r\n", + "created_at": "2024-09-24T17:10:18Z", + "updated_at": "2024-09-24T17:10:19Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": null, + "assignee": null, + "assignees": [], + "requested_reviewers": [ + { + "login": "AnubisNekhet", + "id": 102488279, + "node_id": "U_kgDOBhvY1w", + "avatar_url": "https://avatars.githubusercontent.com/u/102488279?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/AnubisNekhet", + "html_url": "https://github.com/AnubisNekhet", + "followers_url": "https://api.github.com/users/AnubisNekhet/followers", + "following_url": "https://api.github.com/users/AnubisNekhet/following{/other_user}", + "gists_url": "https://api.github.com/users/AnubisNekhet/gists{/gist_id}", + "starred_url": "https://api.github.com/users/AnubisNekhet/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/AnubisNekhet/subscriptions", + "organizations_url": "https://api.github.com/users/AnubisNekhet/orgs", + "repos_url": "https://api.github.com/users/AnubisNekhet/repos", + "events_url": "https://api.github.com/users/AnubisNekhet/events{/privacy}", + "received_events_url": "https://api.github.com/users/AnubisNekhet/received_events", + "type": "User", + "site_admin": false + } + ], + "requested_teams": [], + "labels": [], + "milestone": null, + "draft": false, + "commits_url": "https://api.github.com/repos/catppuccin/userstyles/pulls/1338/commits", + "review_comments_url": "https://api.github.com/repos/catppuccin/userstyles/pulls/1338/comments", + "review_comment_url": "https://api.github.com/repos/catppuccin/userstyles/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/catppuccin/userstyles/issues/1338/comments", + "statuses_url": "https://api.github.com/repos/catppuccin/userstyles/statuses/f45ca8d4227ec310043fbbbe20b5125e7575dc0d", + "head": { + "label": "somerand0mcatt:fix/lastfm", + "ref": "fix/lastfm", + "sha": "f45ca8d4227ec310043fbbbe20b5125e7575dc0d", + "user": { + "login": "somerand0mcatt", + "id": 180954465, + "node_id": "U_kgDOCsklYQ", + "avatar_url": "https://avatars.githubusercontent.com/u/180954465?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/somerand0mcatt", + "html_url": "https://github.com/somerand0mcatt", + "followers_url": "https://api.github.com/users/somerand0mcatt/followers", + "following_url": "https://api.github.com/users/somerand0mcatt/following{/other_user}", + "gists_url": "https://api.github.com/users/somerand0mcatt/gists{/gist_id}", + "starred_url": "https://api.github.com/users/somerand0mcatt/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/somerand0mcatt/subscriptions", + "organizations_url": "https://api.github.com/users/somerand0mcatt/orgs", + "repos_url": "https://api.github.com/users/somerand0mcatt/repos", + "events_url": "https://api.github.com/users/somerand0mcatt/events{/privacy}", + "received_events_url": "https://api.github.com/users/somerand0mcatt/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 854589509, + "node_id": "R_kgDOMvAARQ", + "name": "userstyles", + "full_name": "somerand0mcatt/userstyles", + "private": false, + "owner": { + "login": "somerand0mcatt", + "id": 180954465, + "node_id": "U_kgDOCsklYQ", + "avatar_url": "https://avatars.githubusercontent.com/u/180954465?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/somerand0mcatt", + "html_url": "https://github.com/somerand0mcatt", + "followers_url": "https://api.github.com/users/somerand0mcatt/followers", + "following_url": "https://api.github.com/users/somerand0mcatt/following{/other_user}", + "gists_url": "https://api.github.com/users/somerand0mcatt/gists{/gist_id}", + "starred_url": "https://api.github.com/users/somerand0mcatt/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/somerand0mcatt/subscriptions", + "organizations_url": "https://api.github.com/users/somerand0mcatt/orgs", + "repos_url": "https://api.github.com/users/somerand0mcatt/repos", + "events_url": "https://api.github.com/users/somerand0mcatt/events{/privacy}", + "received_events_url": "https://api.github.com/users/somerand0mcatt/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/somerand0mcatt/userstyles", + "description": "🖌 Soothing pastel userstyles", + "fork": true, + "url": "https://api.github.com/repos/somerand0mcatt/userstyles", + "forks_url": "https://api.github.com/repos/somerand0mcatt/userstyles/forks", + "keys_url": "https://api.github.com/repos/somerand0mcatt/userstyles/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/somerand0mcatt/userstyles/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/somerand0mcatt/userstyles/teams", + "hooks_url": "https://api.github.com/repos/somerand0mcatt/userstyles/hooks", + "issue_events_url": "https://api.github.com/repos/somerand0mcatt/userstyles/issues/events{/number}", + "events_url": "https://api.github.com/repos/somerand0mcatt/userstyles/events", + "assignees_url": "https://api.github.com/repos/somerand0mcatt/userstyles/assignees{/user}", + "branches_url": "https://api.github.com/repos/somerand0mcatt/userstyles/branches{/branch}", + "tags_url": "https://api.github.com/repos/somerand0mcatt/userstyles/tags", + "blobs_url": "https://api.github.com/repos/somerand0mcatt/userstyles/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/somerand0mcatt/userstyles/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/somerand0mcatt/userstyles/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/somerand0mcatt/userstyles/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/somerand0mcatt/userstyles/statuses/{sha}", + "languages_url": "https://api.github.com/repos/somerand0mcatt/userstyles/languages", + "stargazers_url": "https://api.github.com/repos/somerand0mcatt/userstyles/stargazers", + "contributors_url": "https://api.github.com/repos/somerand0mcatt/userstyles/contributors", + "subscribers_url": "https://api.github.com/repos/somerand0mcatt/userstyles/subscribers", + "subscription_url": "https://api.github.com/repos/somerand0mcatt/userstyles/subscription", + "commits_url": "https://api.github.com/repos/somerand0mcatt/userstyles/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/somerand0mcatt/userstyles/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/somerand0mcatt/userstyles/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/somerand0mcatt/userstyles/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/somerand0mcatt/userstyles/contents/{+path}", + "compare_url": "https://api.github.com/repos/somerand0mcatt/userstyles/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/somerand0mcatt/userstyles/merges", + "archive_url": "https://api.github.com/repos/somerand0mcatt/userstyles/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/somerand0mcatt/userstyles/downloads", + "issues_url": "https://api.github.com/repos/somerand0mcatt/userstyles/issues{/number}", + "pulls_url": "https://api.github.com/repos/somerand0mcatt/userstyles/pulls{/number}", + "milestones_url": "https://api.github.com/repos/somerand0mcatt/userstyles/milestones{/number}", + "notifications_url": "https://api.github.com/repos/somerand0mcatt/userstyles/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/somerand0mcatt/userstyles/labels{/name}", + "releases_url": "https://api.github.com/repos/somerand0mcatt/userstyles/releases{/id}", + "deployments_url": "https://api.github.com/repos/somerand0mcatt/userstyles/deployments", + "created_at": "2024-09-09T12:52:15Z", + "updated_at": "2024-09-09T19:37:11Z", + "pushed_at": "2024-09-24T17:09:16Z", + "git_url": "git://github.com/somerand0mcatt/userstyles.git", + "ssh_url": "git@github.com:somerand0mcatt/userstyles.git", + "clone_url": "https://github.com/somerand0mcatt/userstyles.git", + "svn_url": "https://github.com/somerand0mcatt/userstyles", + "homepage": "", + "size": 22390, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Less", + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "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": [], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "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": "catppuccin:main", + "ref": "main", + "sha": "0acf224cde4e26b38b23c4a85f259bff40cd8334", + "user": { + "login": "catppuccin", + "id": 93489351, + "node_id": "O_kgDOBZKIxw", + "avatar_url": "https://avatars.githubusercontent.com/u/93489351?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/catppuccin", + "html_url": "https://github.com/catppuccin", + "followers_url": "https://api.github.com/users/catppuccin/followers", + "following_url": "https://api.github.com/users/catppuccin/following{/other_user}", + "gists_url": "https://api.github.com/users/catppuccin/gists{/gist_id}", + "starred_url": "https://api.github.com/users/catppuccin/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/catppuccin/subscriptions", + "organizations_url": "https://api.github.com/users/catppuccin/orgs", + "repos_url": "https://api.github.com/users/catppuccin/repos", + "events_url": "https://api.github.com/users/catppuccin/events{/privacy}", + "received_events_url": "https://api.github.com/users/catppuccin/received_events", + "type": "Organization", + "site_admin": false + }, + "repo": { + "id": 606608861, + "node_id": "R_kgDOJCgd3Q", + "name": "userstyles", + "full_name": "catppuccin/userstyles", + "private": false, + "owner": { + "login": "catppuccin", + "id": 93489351, + "node_id": "O_kgDOBZKIxw", + "avatar_url": "https://avatars.githubusercontent.com/u/93489351?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/catppuccin", + "html_url": "https://github.com/catppuccin", + "followers_url": "https://api.github.com/users/catppuccin/followers", + "following_url": "https://api.github.com/users/catppuccin/following{/other_user}", + "gists_url": "https://api.github.com/users/catppuccin/gists{/gist_id}", + "starred_url": "https://api.github.com/users/catppuccin/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/catppuccin/subscriptions", + "organizations_url": "https://api.github.com/users/catppuccin/orgs", + "repos_url": "https://api.github.com/users/catppuccin/repos", + "events_url": "https://api.github.com/users/catppuccin/events{/privacy}", + "received_events_url": "https://api.github.com/users/catppuccin/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/catppuccin/userstyles", + "description": "🖌 Soothing pastel userstyles", + "fork": false, + "url": "https://api.github.com/repos/catppuccin/userstyles", + "forks_url": "https://api.github.com/repos/catppuccin/userstyles/forks", + "keys_url": "https://api.github.com/repos/catppuccin/userstyles/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/catppuccin/userstyles/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/catppuccin/userstyles/teams", + "hooks_url": "https://api.github.com/repos/catppuccin/userstyles/hooks", + "issue_events_url": "https://api.github.com/repos/catppuccin/userstyles/issues/events{/number}", + "events_url": "https://api.github.com/repos/catppuccin/userstyles/events", + "assignees_url": "https://api.github.com/repos/catppuccin/userstyles/assignees{/user}", + "branches_url": "https://api.github.com/repos/catppuccin/userstyles/branches{/branch}", + "tags_url": "https://api.github.com/repos/catppuccin/userstyles/tags", + "blobs_url": "https://api.github.com/repos/catppuccin/userstyles/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/catppuccin/userstyles/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/catppuccin/userstyles/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/catppuccin/userstyles/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/catppuccin/userstyles/statuses/{sha}", + "languages_url": "https://api.github.com/repos/catppuccin/userstyles/languages", + "stargazers_url": "https://api.github.com/repos/catppuccin/userstyles/stargazers", + "contributors_url": "https://api.github.com/repos/catppuccin/userstyles/contributors", + "subscribers_url": "https://api.github.com/repos/catppuccin/userstyles/subscribers", + "subscription_url": "https://api.github.com/repos/catppuccin/userstyles/subscription", + "commits_url": "https://api.github.com/repos/catppuccin/userstyles/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/catppuccin/userstyles/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/catppuccin/userstyles/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/catppuccin/userstyles/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/catppuccin/userstyles/contents/{+path}", + "compare_url": "https://api.github.com/repos/catppuccin/userstyles/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/catppuccin/userstyles/merges", + "archive_url": "https://api.github.com/repos/catppuccin/userstyles/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/catppuccin/userstyles/downloads", + "issues_url": "https://api.github.com/repos/catppuccin/userstyles/issues{/number}", + "pulls_url": "https://api.github.com/repos/catppuccin/userstyles/pulls{/number}", + "milestones_url": "https://api.github.com/repos/catppuccin/userstyles/milestones{/number}", + "notifications_url": "https://api.github.com/repos/catppuccin/userstyles/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/catppuccin/userstyles/labels{/name}", + "releases_url": "https://api.github.com/repos/catppuccin/userstyles/releases{/id}", + "deployments_url": "https://api.github.com/repos/catppuccin/userstyles/deployments", + "created_at": "2023-02-26T01:55:38Z", + "updated_at": "2024-09-24T06:08:10Z", + "pushed_at": "2024-09-24T14:27:38Z", + "git_url": "git://github.com/catppuccin/userstyles.git", + "ssh_url": "git@github.com:catppuccin/userstyles.git", + "clone_url": "https://github.com/catppuccin/userstyles.git", + "svn_url": "https://github.com/catppuccin/userstyles", + "homepage": "", + "size": 22934, + "stargazers_count": 460, + "watchers_count": 460, + "language": "Less", + "has_issues": true, + "has_projects": false, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "has_discussions": false, + "forks_count": 135, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 68, + "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": [ + "catppuccin", + "hacktoberfest", + "less", + "meta", + "palette", + "soothing", + "stylus", + "theme", + "userstyles", + "website" + ], + "visibility": "public", + "forks": 135, + "open_issues": 68, + "watchers": 460, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": false, + "allow_rebase_merge": false, + "allow_auto_merge": false, + "delete_branch_on_merge": true, + "allow_update_branch": true, + "use_squash_pr_title_as_default": true, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/catppuccin/userstyles/pulls/1338" + }, + "html": { + "href": "https://github.com/catppuccin/userstyles/pull/1338" + }, + "issue": { + "href": "https://api.github.com/repos/catppuccin/userstyles/issues/1338" + }, + "comments": { + "href": "https://api.github.com/repos/catppuccin/userstyles/issues/1338/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/catppuccin/userstyles/pulls/1338/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/catppuccin/userstyles/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/catppuccin/userstyles/pulls/1338/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/catppuccin/userstyles/statuses/f45ca8d4227ec310043fbbbe20b5125e7575dc0d" + } + }, + "author_association": "CONTRIBUTOR", + "auto_merge": null, + "active_lock_reason": null, + "merged": false, + "mergeable": null, + "rebaseable": null, + "mergeable_state": "unknown", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "maintainer_can_modify": true, + "commits": 1, + "additions": 5, + "deletions": 0, + "changed_files": 1 + }, + "requested_reviewer": { + "login": "AnubisNekhet", + "id": 102488279, + "node_id": "U_kgDOBhvY1w", + "avatar_url": "https://avatars.githubusercontent.com/u/102488279?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/AnubisNekhet", + "html_url": "https://github.com/AnubisNekhet", + "followers_url": "https://api.github.com/users/AnubisNekhet/followers", + "following_url": "https://api.github.com/users/AnubisNekhet/following{/other_user}", + "gists_url": "https://api.github.com/users/AnubisNekhet/gists{/gist_id}", + "starred_url": "https://api.github.com/users/AnubisNekhet/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/AnubisNekhet/subscriptions", + "organizations_url": "https://api.github.com/users/AnubisNekhet/orgs", + "repos_url": "https://api.github.com/users/AnubisNekhet/repos", + "events_url": "https://api.github.com/users/AnubisNekhet/events{/privacy}", + "received_events_url": "https://api.github.com/users/AnubisNekhet/received_events", + "type": "User", + "site_admin": false + }, + "repository": { + "id": 606608861, + "node_id": "R_kgDOJCgd3Q", + "name": "userstyles", + "full_name": "catppuccin/userstyles", + "private": false, + "owner": { + "login": "catppuccin", + "id": 93489351, + "node_id": "O_kgDOBZKIxw", + "avatar_url": "https://avatars.githubusercontent.com/u/93489351?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/catppuccin", + "html_url": "https://github.com/catppuccin", + "followers_url": "https://api.github.com/users/catppuccin/followers", + "following_url": "https://api.github.com/users/catppuccin/following{/other_user}", + "gists_url": "https://api.github.com/users/catppuccin/gists{/gist_id}", + "starred_url": "https://api.github.com/users/catppuccin/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/catppuccin/subscriptions", + "organizations_url": "https://api.github.com/users/catppuccin/orgs", + "repos_url": "https://api.github.com/users/catppuccin/repos", + "events_url": "https://api.github.com/users/catppuccin/events{/privacy}", + "received_events_url": "https://api.github.com/users/catppuccin/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/catppuccin/userstyles", + "description": "🖌 Soothing pastel userstyles", + "fork": false, + "url": "https://api.github.com/repos/catppuccin/userstyles", + "forks_url": "https://api.github.com/repos/catppuccin/userstyles/forks", + "keys_url": "https://api.github.com/repos/catppuccin/userstyles/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/catppuccin/userstyles/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/catppuccin/userstyles/teams", + "hooks_url": "https://api.github.com/repos/catppuccin/userstyles/hooks", + "issue_events_url": "https://api.github.com/repos/catppuccin/userstyles/issues/events{/number}", + "events_url": "https://api.github.com/repos/catppuccin/userstyles/events", + "assignees_url": "https://api.github.com/repos/catppuccin/userstyles/assignees{/user}", + "branches_url": "https://api.github.com/repos/catppuccin/userstyles/branches{/branch}", + "tags_url": "https://api.github.com/repos/catppuccin/userstyles/tags", + "blobs_url": "https://api.github.com/repos/catppuccin/userstyles/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/catppuccin/userstyles/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/catppuccin/userstyles/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/catppuccin/userstyles/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/catppuccin/userstyles/statuses/{sha}", + "languages_url": "https://api.github.com/repos/catppuccin/userstyles/languages", + "stargazers_url": "https://api.github.com/repos/catppuccin/userstyles/stargazers", + "contributors_url": "https://api.github.com/repos/catppuccin/userstyles/contributors", + "subscribers_url": "https://api.github.com/repos/catppuccin/userstyles/subscribers", + "subscription_url": "https://api.github.com/repos/catppuccin/userstyles/subscription", + "commits_url": "https://api.github.com/repos/catppuccin/userstyles/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/catppuccin/userstyles/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/catppuccin/userstyles/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/catppuccin/userstyles/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/catppuccin/userstyles/contents/{+path}", + "compare_url": "https://api.github.com/repos/catppuccin/userstyles/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/catppuccin/userstyles/merges", + "archive_url": "https://api.github.com/repos/catppuccin/userstyles/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/catppuccin/userstyles/downloads", + "issues_url": "https://api.github.com/repos/catppuccin/userstyles/issues{/number}", + "pulls_url": "https://api.github.com/repos/catppuccin/userstyles/pulls{/number}", + "milestones_url": "https://api.github.com/repos/catppuccin/userstyles/milestones{/number}", + "notifications_url": "https://api.github.com/repos/catppuccin/userstyles/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/catppuccin/userstyles/labels{/name}", + "releases_url": "https://api.github.com/repos/catppuccin/userstyles/releases{/id}", + "deployments_url": "https://api.github.com/repos/catppuccin/userstyles/deployments", + "created_at": "2023-02-26T01:55:38Z", + "updated_at": "2024-09-24T06:08:10Z", + "pushed_at": "2024-09-24T14:27:38Z", + "git_url": "git://github.com/catppuccin/userstyles.git", + "ssh_url": "git@github.com:catppuccin/userstyles.git", + "clone_url": "https://github.com/catppuccin/userstyles.git", + "svn_url": "https://github.com/catppuccin/userstyles", + "homepage": "", + "size": 22934, + "stargazers_count": 460, + "watchers_count": 460, + "language": "Less", + "has_issues": true, + "has_projects": false, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "has_discussions": false, + "forks_count": 135, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 68, + "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": [ + "catppuccin", + "hacktoberfest", + "less", + "meta", + "palette", + "soothing", + "stylus", + "theme", + "userstyles", + "website" + ], + "visibility": "public", + "forks": 135, + "open_issues": 68, + "watchers": 460, + "default_branch": "main", + "custom_properties": { + "whiskers": "not_applicable" + } + }, + "organization": { + "login": "catppuccin", + "id": 93489351, + "node_id": "O_kgDOBZKIxw", + "url": "https://api.github.com/orgs/catppuccin", + "repos_url": "https://api.github.com/orgs/catppuccin/repos", + "events_url": "https://api.github.com/orgs/catppuccin/events", + "hooks_url": "https://api.github.com/orgs/catppuccin/hooks", + "issues_url": "https://api.github.com/orgs/catppuccin/issues", + "members_url": "https://api.github.com/orgs/catppuccin/members{/member}", + "public_members_url": "https://api.github.com/orgs/catppuccin/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/93489351?v=4", + "description": "Soothing pastel theme for the high-spirited!" + }, + "sender": { + "login": "somerand0mcatt", + "id": 180954465, + "node_id": "U_kgDOCsklYQ", + "avatar_url": "https://avatars.githubusercontent.com/u/180954465?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/somerand0mcatt", + "html_url": "https://github.com/somerand0mcatt", + "followers_url": "https://api.github.com/users/somerand0mcatt/followers", + "following_url": "https://api.github.com/users/somerand0mcatt/following{/other_user}", + "gists_url": "https://api.github.com/users/somerand0mcatt/gists{/gist_id}", + "starred_url": "https://api.github.com/users/somerand0mcatt/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/somerand0mcatt/subscriptions", + "organizations_url": "https://api.github.com/users/somerand0mcatt/orgs", + "repos_url": "https://api.github.com/users/somerand0mcatt/repos", + "events_url": "https://api.github.com/users/somerand0mcatt/events{/privacy}", + "received_events_url": "https://api.github.com/users/somerand0mcatt/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/snapshots/pull_request/multiple_reviewers.snap b/snapshots/pull_request/multiple_reviewers.snap index 09a4e00..527f4b8 100644 --- a/snapshots/pull_request/multiple_reviewers.snap +++ b/snapshots/pull_request/multiple_reviewers.snap @@ -4,7 +4,7 @@ info: author_name_length: 16 colour_hex: "#89B4FA" description_length: 0 - title_length: 100 + title_length: 105 --- embeds: - author: @@ -13,5 +13,5 @@ embeds: url: "https://github.com/Thomas-Philippot" color: 9024762 description: ~ - title: "[catppuccin/userstyles] Pull request review requested from userstyles-staff: #1337 feat(gitlab): ..." + title: "[catppuccin/not-userstyles] Pull request review requested from userstyles-staff: #1337 feat(gitlab): init" url: "https://github.com/catppuccin/userstyles/pull/1337" diff --git a/src/embed_builder.rs b/src/embed_builder.rs index fbfe6a9..e82d3c3 100644 --- a/src/embed_builder.rs +++ b/src/embed_builder.rs @@ -2,7 +2,7 @@ use octocrab::models::Author; use serde_json::json; use thiserror::Error; -const MAX_TITLE_LENGTH: usize = 100; +const MAX_TITLE_LENGTH: usize = 256; const MAX_DESCRIPTION_LENGTH: usize = 640; const MAX_AUTHOR_NAME_LENGTH: usize = 256; diff --git a/src/events/pull_request.rs b/src/events/pull_request.rs index a9934f9..c8d1648 100644 --- a/src/events/pull_request.rs +++ b/src/events/pull_request.rs @@ -22,7 +22,7 @@ pub fn make_embed( let mut embed = EmbedBuilder::default(); - let repo_name = repo.full_name.unwrap_or(repo.name); + let repo_name = repo.full_name.as_ref().unwrap_or(&repo.name); embed.title(&format!( "[{}] Pull request {}: #{} {}", @@ -51,6 +51,11 @@ pub fn make_embed( PullRequestWebhookEventAction::ReadyForReview => "ready for review".to_string(), PullRequestWebhookEventAction::Reopened => "reopened".to_string(), PullRequestWebhookEventAction::ReviewRequested => { + // userstyles is a monorepo with codeowners so generates a lot of noise in this case + if repo.name == "userstyles" { + return Ok(None); + } + let mut reviewer_names = vec![]; reviewer_names.extend( specifics @@ -122,9 +127,22 @@ mod tests { opened_by_bot = { "opened_by_bot" }, closed = { "closed" }, reopened = { "reopened" }, - multiple_reviewers = { "multiple_reviewers" } + multiple_reviewers = { "multiple_reviewers" }, )] fn snapshot(event_type: &str) { snapshot_test!("pull_request", event_type); } + + #[test] + fn test_userstyles_is_banned() { + let embed = crate::events::make_embed( + octocrab::models::webhook_events::WebhookEvent::try_from_header_and_body( + "pull_request", + include_str!("../../fixtures/pull_request/userstyles_review.json"), + ) + .expect("event fixture is valid"), + ) + .expect("make_embed should succeed"); + assert_eq!(embed, None, "userstyles should be ignored"); + } }