From 0dc370038df3235c5a5895db68476d67496f978d Mon Sep 17 00:00:00 2001 From: Eleanor Goh Date: Mon, 22 Apr 2024 10:28:00 -0700 Subject: [PATCH 1/5] Repository Renamed event --- .../org/kohsuke/github/GHEventPayload.java | 39 +++++ .../kohsuke/github/GHEventPayloadTest.java | 12 ++ .../repository_renamed.json | 158 ++++++++++++++++++ 3 files changed, 209 insertions(+) create mode 100644 src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_renamed.json diff --git a/src/main/java/org/kohsuke/github/GHEventPayload.java b/src/main/java/org/kohsuke/github/GHEventPayload.java index 91cbde47a..b983ebc9c 100644 --- a/src/main/java/org/kohsuke/github/GHEventPayload.java +++ b/src/main/java/org/kohsuke/github/GHEventPayload.java @@ -1448,6 +1448,45 @@ public static class Repository extends GHEventPayload { } + /** + * A repository was renamed or transferred. + * + * @see + * repository event + * @see Repositories + */ + public static class RepositoryChanges extends GHEventPayload { + private GHRepositoryChanges changes; + + public GHRepositoryChanges getChanges() { + return changes; + } + + public static class GHRepositoryChanges { + private FromRepository repository; + + public FromRepository getRepository() { + return repository; + } + + public static class FromRepository { + private FromName name; + + public FromName getName() { + return name; + } + } + + public static class FromName { + private String from; + + public String getFrom() { + return from; + } + } + } + } + /** * A git commit status was changed. * diff --git a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java index c346d368d..bf1865a5f 100644 --- a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java +++ b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java @@ -772,6 +772,18 @@ public void repository() throws Exception { assertThat(event.getSender().getLogin(), is("baxterthehacker")); } + @Test + public void repository_renamed() throws Exception { + final GHEventPayload.RepositoryChanges event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.RepositoryChanges.class); + assertThat(event.getAction(), is("renamed")); + assertThat(event.getChanges().getRepository().getName().getFrom(), is("egoh-test-repo")); + assertThat(event.getRepository().getName(), is("egoh-test-repo-0")); + assertThat(event.getRepository().getOwner().getLogin(), is("corp")); + assertThat(event.getOrganization().getLogin(), is("corp")); + assertThat(event.getSender().getLogin(), is("egoh")); + } + /** * Status. * diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_renamed.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_renamed.json new file mode 100644 index 000000000..de52cecdf --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_renamed.json @@ -0,0 +1,158 @@ +{ + "action": "renamed", + "changes": { + "repository": { + "name": { + "from": "egoh-test-repo" + } + } + }, + "repository": { + "id": 52123, + "node_id": "MDEwOlJlcG9zaXRvcnk1MjEyMw==", + "name": "egoh-test-repo-0", + "full_name": "corp/egoh-test-repo-0", + "private": true, + "owner": { + "login": "corp", + "id": 5, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU=", + "avatar_url": "https://github-staging.netflix.net/avatars/u/5?", + "gravatar_id": "", + "url": "https://github-staging.netflix.net/api/v3/users/corp", + "html_url": "https://github-staging.netflix.net/corp", + "followers_url": "https://github-staging.netflix.net/api/v3/users/corp/followers", + "following_url": "https://github-staging.netflix.net/api/v3/users/corp/following{/other_user}", + "gists_url": "https://github-staging.netflix.net/api/v3/users/corp/gists{/gist_id}", + "starred_url": "https://github-staging.netflix.net/api/v3/users/corp/starred{/owner}{/repo}", + "subscriptions_url": "https://github-staging.netflix.net/api/v3/users/corp/subscriptions", + "organizations_url": "https://github-staging.netflix.net/api/v3/users/corp/orgs", + "repos_url": "https://github-staging.netflix.net/api/v3/users/corp/repos", + "events_url": "https://github-staging.netflix.net/api/v3/users/corp/events{/privacy}", + "received_events_url": "https://github-staging.netflix.net/api/v3/users/corp/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github-staging.netflix.net/corp/egoh-test-repo-0", + "description": null, + "fork": false, + "url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0", + "forks_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/forks", + "keys_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/keys{/key_id}", + "collaborators_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/collaborators{/collaborator}", + "teams_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/teams", + "hooks_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/hooks", + "issue_events_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/issues/events{/number}", + "events_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/events", + "assignees_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/assignees{/user}", + "branches_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/branches{/branch}", + "tags_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/tags", + "blobs_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/git/blobs{/sha}", + "git_tags_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/git/tags{/sha}", + "git_refs_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/git/refs{/sha}", + "trees_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/git/trees{/sha}", + "statuses_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/statuses/{sha}", + "languages_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/languages", + "stargazers_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/stargazers", + "contributors_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/contributors", + "subscribers_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/subscribers", + "subscription_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/subscription", + "commits_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/commits{/sha}", + "git_commits_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/git/commits{/sha}", + "comments_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/comments{/number}", + "issue_comment_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/issues/comments{/number}", + "contents_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/contents/{+path}", + "compare_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/compare/{base}...{head}", + "merges_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/merges", + "archive_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/{archive_format}{/ref}", + "downloads_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/downloads", + "issues_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/issues{/number}", + "pulls_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/pulls{/number}", + "milestones_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/milestones{/number}", + "notifications_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/notifications{?since,all,participating}", + "labels_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/labels{/name}", + "releases_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/releases{/id}", + "deployments_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/deployments", + "created_at": "2024-04-19T21:42:10Z", + "updated_at": "2024-04-19T21:52:25Z", + "pushed_at": "2024-04-19T21:42:12Z", + "git_url": "git://github-staging.netflix.net/corp/egoh-test-repo-0.git", + "ssh_url": "git@github-staging.netflix.net:corp/egoh-test-repo-0.git", + "clone_url": "https://github-staging.netflix.net/corp/egoh-test-repo-0.git", + "svn_url": "https://github-staging.netflix.net/corp/egoh-test-repo-0", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + + ], + "visibility": "internal", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main" + }, + "organization": { + "login": "corp", + "id": 5, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU=", + "url": "https://github-staging.netflix.net/api/v3/orgs/corp", + "repos_url": "https://github-staging.netflix.net/api/v3/orgs/corp/repos", + "events_url": "https://github-staging.netflix.net/api/v3/orgs/corp/events", + "hooks_url": "https://github-staging.netflix.net/api/v3/orgs/corp/hooks", + "issues_url": "https://github-staging.netflix.net/api/v3/orgs/corp/issues", + "members_url": "https://github-staging.netflix.net/api/v3/orgs/corp/members{/member}", + "public_members_url": "https://github-staging.netflix.net/api/v3/orgs/corp/public_members{/member}", + "avatar_url": "https://github-staging.netflix.net/avatars/u/5?", + "description": null + }, + "enterprise": { + "id": 1, + "slug": "netflix", + "name": "Netflix", + "node_id": "MDEwOkVudGVycHJpc2Ux", + "avatar_url": "https://github-staging.netflix.net/avatars/b/1?", + "description": null, + "website_url": null, + "html_url": "https://github-staging.netflix.net/enterprises/netflix", + "created_at": "2023-10-12T06:56:57Z", + "updated_at": "2023-11-08T18:37:49Z" + }, + "sender": { + "login": "egoh", + "id": 30, + "node_id": "MDQ6VXNlcjMw", + "avatar_url": "https://github-staging.netflix.net/avatars/u/30?", + "gravatar_id": "", + "url": "https://github-staging.netflix.net/api/v3/users/egoh", + "html_url": "https://github-staging.netflix.net/egoh", + "followers_url": "https://github-staging.netflix.net/api/v3/users/egoh/followers", + "following_url": "https://github-staging.netflix.net/api/v3/users/egoh/following{/other_user}", + "gists_url": "https://github-staging.netflix.net/api/v3/users/egoh/gists{/gist_id}", + "starred_url": "https://github-staging.netflix.net/api/v3/users/egoh/starred{/owner}{/repo}", + "subscriptions_url": "https://github-staging.netflix.net/api/v3/users/egoh/subscriptions", + "organizations_url": "https://github-staging.netflix.net/api/v3/users/egoh/orgs", + "repos_url": "https://github-staging.netflix.net/api/v3/users/egoh/repos", + "events_url": "https://github-staging.netflix.net/api/v3/users/egoh/events{/privacy}", + "received_events_url": "https://github-staging.netflix.net/api/v3/users/egoh/received_events", + "type": "User", + "site_admin": true + } +} \ No newline at end of file From f8afbbbe473992bd9fc35a1c89b34c461cfaa45b Mon Sep 17 00:00:00 2001 From: Eleanor Goh Date: Tue, 23 Apr 2024 12:05:43 -0700 Subject: [PATCH 2/5] Repository Transferred event --- .../org/kohsuke/github/GHEventPayload.java | 22 +++ .../kohsuke/github/GHEventPayloadTest.java | 10 + .../repository_transferred.json | 177 ++++++++++++++++++ 3 files changed, 209 insertions(+) create mode 100644 src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_transferred.json diff --git a/src/main/java/org/kohsuke/github/GHEventPayload.java b/src/main/java/org/kohsuke/github/GHEventPayload.java index b983ebc9c..e70b37a9b 100644 --- a/src/main/java/org/kohsuke/github/GHEventPayload.java +++ b/src/main/java/org/kohsuke/github/GHEventPayload.java @@ -1464,6 +1464,28 @@ public GHRepositoryChanges getChanges() { public static class GHRepositoryChanges { private FromRepository repository; + private Owner owner; + + public Owner getOwner() { + return owner; + } + + public static class Owner { + private FromOwner from; + + public FromOwner getFrom() { + return from; + } + } + + public static class FromOwner { + private GHUser user; + + @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected") + public GHUser getUser() { + return user; + } + } public FromRepository getRepository() { return repository; diff --git a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java index bf1865a5f..1ffc068a0 100644 --- a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java +++ b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java @@ -784,6 +784,16 @@ public void repository_renamed() throws Exception { assertThat(event.getSender().getLogin(), is("egoh")); } + @Test + public void repository_transferred() throws Exception { + final GHEventPayload.RepositoryChanges event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.RepositoryChanges.class); + assertThat(event.getAction(), is("transferred")); + assertThat(event.getChanges().getOwner().getFrom().getUser().getLogin(), is("egoh")); + assertThat(event.getChanges().getOwner().getFrom().getUser().getId(), is(30L)); + assertThat(event.getChanges().getOwner().getFrom().getUser().getType(), is("User")); + } + /** * Status. * diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_transferred.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_transferred.json new file mode 100644 index 000000000..96e53a15b --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_transferred.json @@ -0,0 +1,177 @@ +{ + "action": "transferred", + "changes": { + "owner": { + "from": { + "user": { + "login": "egoh", + "id": 30, + "node_id": "MDQ6VXNlcjMw", + "avatar_url": "https://github-staging.netflix.net/avatars/u/30?", + "gravatar_id": "", + "url": "https://github-staging.netflix.net/api/v3/users/egoh", + "html_url": "https://github-staging.netflix.net/egoh", + "followers_url": "https://github-staging.netflix.net/api/v3/users/egoh/followers", + "following_url": "https://github-staging.netflix.net/api/v3/users/egoh/following{/other_user}", + "gists_url": "https://github-staging.netflix.net/api/v3/users/egoh/gists{/gist_id}", + "starred_url": "https://github-staging.netflix.net/api/v3/users/egoh/starred{/owner}{/repo}", + "subscriptions_url": "https://github-staging.netflix.net/api/v3/users/egoh/subscriptions", + "organizations_url": "https://github-staging.netflix.net/api/v3/users/egoh/orgs", + "repos_url": "https://github-staging.netflix.net/api/v3/users/egoh/repos", + "events_url": "https://github-staging.netflix.net/api/v3/users/egoh/events{/privacy}", + "received_events_url": "https://github-staging.netflix.net/api/v3/users/egoh/received_events", + "type": "User", + "site_admin": true + } + } + } + }, + "repository": { + "id": 52124, + "node_id": "MDEwOlJlcG9zaXRvcnk1MjEyNA==", + "name": "egoh-test-repo-2", + "full_name": "corp/egoh-test-repo-2", + "private": false, + "owner": { + "login": "corp", + "id": 5, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU=", + "avatar_url": "https://github-staging.netflix.net/avatars/u/5?", + "gravatar_id": "", + "url": "https://github-staging.netflix.net/api/v3/users/corp", + "html_url": "https://github-staging.netflix.net/corp", + "followers_url": "https://github-staging.netflix.net/api/v3/users/corp/followers", + "following_url": "https://github-staging.netflix.net/api/v3/users/corp/following{/other_user}", + "gists_url": "https://github-staging.netflix.net/api/v3/users/corp/gists{/gist_id}", + "starred_url": "https://github-staging.netflix.net/api/v3/users/corp/starred{/owner}{/repo}", + "subscriptions_url": "https://github-staging.netflix.net/api/v3/users/corp/subscriptions", + "organizations_url": "https://github-staging.netflix.net/api/v3/users/corp/orgs", + "repos_url": "https://github-staging.netflix.net/api/v3/users/corp/repos", + "events_url": "https://github-staging.netflix.net/api/v3/users/corp/events{/privacy}", + "received_events_url": "https://github-staging.netflix.net/api/v3/users/corp/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github-staging.netflix.net/corp/egoh-test-repo-2", + "description": null, + "fork": false, + "url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2", + "forks_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/forks", + "keys_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/keys{/key_id}", + "collaborators_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/collaborators{/collaborator}", + "teams_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/teams", + "hooks_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/hooks", + "issue_events_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/issues/events{/number}", + "events_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/events", + "assignees_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/assignees{/user}", + "branches_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/branches{/branch}", + "tags_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/tags", + "blobs_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/git/blobs{/sha}", + "git_tags_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/git/tags{/sha}", + "git_refs_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/git/refs{/sha}", + "trees_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/git/trees{/sha}", + "statuses_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/statuses/{sha}", + "languages_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/languages", + "stargazers_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/stargazers", + "contributors_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/contributors", + "subscribers_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/subscribers", + "subscription_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/subscription", + "commits_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/commits{/sha}", + "git_commits_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/git/commits{/sha}", + "comments_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/comments{/number}", + "issue_comment_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/issues/comments{/number}", + "contents_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/contents/{+path}", + "compare_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/compare/{base}...{head}", + "merges_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/merges", + "archive_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/{archive_format}{/ref}", + "downloads_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/downloads", + "issues_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/issues{/number}", + "pulls_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/pulls{/number}", + "milestones_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/milestones{/number}", + "notifications_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/notifications{?since,all,participating}", + "labels_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/labels{/name}", + "releases_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/releases{/id}", + "deployments_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/deployments", + "created_at": "2024-04-19T21:47:45Z", + "updated_at": "2024-04-19T21:48:07Z", + "pushed_at": "2024-04-19T21:47:46Z", + "git_url": "git://github-staging.netflix.net/corp/egoh-test-repo-2.git", + "ssh_url": "git@github-staging.netflix.net:corp/egoh-test-repo-2.git", + "clone_url": "https://github-staging.netflix.net/corp/egoh-test-repo-2.git", + "svn_url": "https://github-staging.netflix.net/corp/egoh-test-repo-2", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + + ], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main" + }, + "organization": { + "login": "corp", + "id": 5, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjU=", + "url": "https://github-staging.netflix.net/api/v3/orgs/corp", + "repos_url": "https://github-staging.netflix.net/api/v3/orgs/corp/repos", + "events_url": "https://github-staging.netflix.net/api/v3/orgs/corp/events", + "hooks_url": "https://github-staging.netflix.net/api/v3/orgs/corp/hooks", + "issues_url": "https://github-staging.netflix.net/api/v3/orgs/corp/issues", + "members_url": "https://github-staging.netflix.net/api/v3/orgs/corp/members{/member}", + "public_members_url": "https://github-staging.netflix.net/api/v3/orgs/corp/public_members{/member}", + "avatar_url": "https://github-staging.netflix.net/avatars/u/5?", + "description": null + }, + "enterprise": { + "id": 1, + "slug": "netflix", + "name": "Netflix", + "node_id": "MDEwOkVudGVycHJpc2Ux", + "avatar_url": "https://github-staging.netflix.net/avatars/b/1?", + "description": null, + "website_url": null, + "html_url": "https://github-staging.netflix.net/enterprises/netflix", + "created_at": "2023-10-12T06:56:57Z", + "updated_at": "2023-11-08T18:37:49Z" + }, + "sender": { + "login": "egoh", + "id": 30, + "node_id": "MDQ6VXNlcjMw", + "avatar_url": "https://github-staging.netflix.net/avatars/u/30?", + "gravatar_id": "", + "url": "https://github-staging.netflix.net/api/v3/users/egoh", + "html_url": "https://github-staging.netflix.net/egoh", + "followers_url": "https://github-staging.netflix.net/api/v3/users/egoh/followers", + "following_url": "https://github-staging.netflix.net/api/v3/users/egoh/following{/other_user}", + "gists_url": "https://github-staging.netflix.net/api/v3/users/egoh/gists{/gist_id}", + "starred_url": "https://github-staging.netflix.net/api/v3/users/egoh/starred{/owner}{/repo}", + "subscriptions_url": "https://github-staging.netflix.net/api/v3/users/egoh/subscriptions", + "organizations_url": "https://github-staging.netflix.net/api/v3/users/egoh/orgs", + "repos_url": "https://github-staging.netflix.net/api/v3/users/egoh/repos", + "events_url": "https://github-staging.netflix.net/api/v3/users/egoh/events{/privacy}", + "received_events_url": "https://github-staging.netflix.net/api/v3/users/egoh/received_events", + "type": "User", + "site_admin": true + } +} \ No newline at end of file From e685367f0877b9ee109fd6b23c07f6adad48273b Mon Sep 17 00:00:00 2001 From: Eleanor Goh Date: Wed, 24 Apr 2024 16:47:10 -0700 Subject: [PATCH 3/5] Refactor --- .../org/kohsuke/github/GHEventPayload.java | 51 +--------- .../kohsuke/github/GHRepositoryChanges.java | 95 +++++++++++++++++++ .../kohsuke/github/GHEventPayloadTest.java | 12 +++ 3 files changed, 112 insertions(+), 46 deletions(-) create mode 100644 src/main/java/org/kohsuke/github/GHRepositoryChanges.java diff --git a/src/main/java/org/kohsuke/github/GHEventPayload.java b/src/main/java/org/kohsuke/github/GHEventPayload.java index e70b37a9b..965b51b77 100644 --- a/src/main/java/org/kohsuke/github/GHEventPayload.java +++ b/src/main/java/org/kohsuke/github/GHEventPayload.java @@ -1458,55 +1458,14 @@ public static class Repository extends GHEventPayload { public static class RepositoryChanges extends GHEventPayload { private GHRepositoryChanges changes; + /** + * Get changes. + * + * @return GHRepositoryChanges + */ public GHRepositoryChanges getChanges() { return changes; } - - public static class GHRepositoryChanges { - private FromRepository repository; - private Owner owner; - - public Owner getOwner() { - return owner; - } - - public static class Owner { - private FromOwner from; - - public FromOwner getFrom() { - return from; - } - } - - public static class FromOwner { - private GHUser user; - - @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected") - public GHUser getUser() { - return user; - } - } - - public FromRepository getRepository() { - return repository; - } - - public static class FromRepository { - private FromName name; - - public FromName getName() { - return name; - } - } - - public static class FromName { - private String from; - - public String getFrom() { - return from; - } - } - } } /** diff --git a/src/main/java/org/kohsuke/github/GHRepositoryChanges.java b/src/main/java/org/kohsuke/github/GHRepositoryChanges.java new file mode 100644 index 000000000..e242e3f4f --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHRepositoryChanges.java @@ -0,0 +1,95 @@ +package org.kohsuke.github; + +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + +/** + * Changes made to a repository. + */ +@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") +public class GHRepositoryChanges { + private FromRepository repository; + private Owner owner; + + /** + * Get outer owner object. + * + * @return Owner + */ + public Owner getOwner() { + return owner; + } + + /** + * Outer object of owner from whom this repository was transferred. + */ + public static class Owner { + private FromOwner from; + + /** + * Get in owner object. + * + * @return FromOwner + */ + public FromOwner getFrom() { + return from; + } + } + + /** + * Owner from whom this repository was transferred. + */ + public static class FromOwner { + private GHUser user; + + /** + * Get user from which this repository was transferrred. + * + * @return user + */ + @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected") + public GHUser getUser() { + return user; + } + } + + /** + * Get repository. + * + * @return FromRepository + */ + public FromRepository getRepository() { + return repository; + } + + /** + * Repository object from which the name was changed. + */ + public static class FromRepository { + private FromName name; + + /** + * Get top level object for the previous name of the repository. + * + * @return FromName + */ + public FromName getName() { + return name; + } + } + + /** + * Repository name that was changed. + */ + public static class FromName { + private String from; + + /** + * Get previous name of the repository before rename. + * + * @return String + */ + public String getFrom() { + return from; + } + } +} diff --git a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java index 1ffc068a0..65f94a9f1 100644 --- a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java +++ b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java @@ -772,6 +772,12 @@ public void repository() throws Exception { assertThat(event.getSender().getLogin(), is("baxterthehacker")); } + /** + * Repository renamed. + * + * @throws Exception + * the exception + */ @Test public void repository_renamed() throws Exception { final GHEventPayload.RepositoryChanges event = GitHub.offline() @@ -784,6 +790,12 @@ public void repository_renamed() throws Exception { assertThat(event.getSender().getLogin(), is("egoh")); } + /** + * Repository ownership transferred. + * + * @throws Exception + * the exception + */ @Test public void repository_transferred() throws Exception { final GHEventPayload.RepositoryChanges event = GitHub.offline() From 075d6278df79f00a1e788ef2226d55898160944e Mon Sep 17 00:00:00 2001 From: Eleanor Goh Date: Thu, 25 Apr 2024 13:43:06 -0700 Subject: [PATCH 4/5] Generate data from dotcom and add support for transferred to user payloads --- .../kohsuke/github/GHRepositoryChanges.java | 13 +- .../kohsuke/github/GHEventPayloadTest.java | 35 ++- .../repository_renamed.json | 211 +++++++++--------- .../repository_transferred.json | 177 --------------- .../repository_transferred_to_org.json | 168 ++++++++++++++ .../repository_transferred_to_user.json | 145 ++++++++++++ 6 files changed, 452 insertions(+), 297 deletions(-) delete mode 100644 src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_transferred.json create mode 100644 src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_transferred_to_org.json create mode 100644 src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_transferred_to_user.json diff --git a/src/main/java/org/kohsuke/github/GHRepositoryChanges.java b/src/main/java/org/kohsuke/github/GHRepositoryChanges.java index e242e3f4f..9c9aa578d 100644 --- a/src/main/java/org/kohsuke/github/GHRepositoryChanges.java +++ b/src/main/java/org/kohsuke/github/GHRepositoryChanges.java @@ -40,9 +40,10 @@ public FromOwner getFrom() { */ public static class FromOwner { private GHUser user; + private GHOrganization organization; /** - * Get user from which this repository was transferrred. + * Get user from which this repository was transferred. * * @return user */ @@ -50,6 +51,16 @@ public static class FromOwner { public GHUser getUser() { return user; } + + /** + * Get organization from which this repository was transferred. + * + * @return GHOrganization + */ + @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected") + public GHOrganization getOrganization() { + return organization; + } } /** diff --git a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java index 65f94a9f1..212066d5a 100644 --- a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java +++ b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java @@ -783,29 +783,46 @@ public void repository_renamed() throws Exception { final GHEventPayload.RepositoryChanges event = GitHub.offline() .parseEventPayload(payload.asReader(), GHEventPayload.RepositoryChanges.class); assertThat(event.getAction(), is("renamed")); - assertThat(event.getChanges().getRepository().getName().getFrom(), is("egoh-test-repo")); - assertThat(event.getRepository().getName(), is("egoh-test-repo-0")); - assertThat(event.getRepository().getOwner().getLogin(), is("corp")); - assertThat(event.getOrganization().getLogin(), is("corp")); - assertThat(event.getSender().getLogin(), is("egoh")); + assertThat(event.getChanges().getRepository().getName().getFrom(), is("react-workshop")); + assertThat(event.getRepository().getName(), is("react-workshop-renamed")); + assertThat(event.getRepository().getOwner().getLogin(), is("EJG-Organization")); + assertThat(event.getOrganization().getLogin(), is("EJG-Organization")); + assertThat(event.getSender().getLogin(), is("eleanorgoh")); } /** - * Repository ownership transferred. + * Repository ownership transferred to an organization. * * @throws Exception * the exception */ @Test - public void repository_transferred() throws Exception { + public void repository_transferred_to_org() throws Exception { final GHEventPayload.RepositoryChanges event = GitHub.offline() .parseEventPayload(payload.asReader(), GHEventPayload.RepositoryChanges.class); assertThat(event.getAction(), is("transferred")); - assertThat(event.getChanges().getOwner().getFrom().getUser().getLogin(), is("egoh")); - assertThat(event.getChanges().getOwner().getFrom().getUser().getId(), is(30L)); + assertThat(event.getChanges().getOwner().getFrom().getUser().getLogin(), is("eleanorgoh")); + assertThat(event.getChanges().getOwner().getFrom().getUser().getId(), is(66235606L)); assertThat(event.getChanges().getOwner().getFrom().getUser().getType(), is("User")); } + /** + * Repository ownership transferred to a user. + * + * @throws Exception + * the exception + */ + @Test + public void repository_transferred_to_user() throws Exception { + final GHEventPayload.RepositoryChanges event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.RepositoryChanges.class); + assertThat(event.getAction(), is("transferred")); + assertThat(event.getChanges().getOwner().getFrom().getOrganization().getLogin(), is("EJG-Organization")); + assertThat(event.getChanges().getOwner().getFrom().getOrganization().getId(), is(168135412L)); + assertThat(event.getRepository().getOwner().getLogin(), is("eleanorgoh")); + assertThat(event.getRepository().getOwner().getType(), is("User")); + } + /** * Status. * diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_renamed.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_renamed.json index de52cecdf..bd278f010 100644 --- a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_renamed.json +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_renamed.json @@ -3,89 +3,89 @@ "changes": { "repository": { "name": { - "from": "egoh-test-repo" + "from": "react-workshop" } } }, "repository": { - "id": 52123, - "node_id": "MDEwOlJlcG9zaXRvcnk1MjEyMw==", - "name": "egoh-test-repo-0", - "full_name": "corp/egoh-test-repo-0", - "private": true, + "id": 360319037, + "node_id": "MDEwOlJlcG9zaXRvcnkzNjAzMTkwMzc=", + "name": "react-workshop-renamed", + "full_name": "EJG-Organization/react-workshop-renamed", + "private": false, "owner": { - "login": "corp", - "id": 5, - "node_id": "MDEyOk9yZ2FuaXphdGlvbjU=", - "avatar_url": "https://github-staging.netflix.net/avatars/u/5?", + "login": "EJG-Organization", + "id": 168135412, + "node_id": "O_kgDOCgWK9A", + "avatar_url": "https://avatars.githubusercontent.com/u/168135412?v=4", "gravatar_id": "", - "url": "https://github-staging.netflix.net/api/v3/users/corp", - "html_url": "https://github-staging.netflix.net/corp", - "followers_url": "https://github-staging.netflix.net/api/v3/users/corp/followers", - "following_url": "https://github-staging.netflix.net/api/v3/users/corp/following{/other_user}", - "gists_url": "https://github-staging.netflix.net/api/v3/users/corp/gists{/gist_id}", - "starred_url": "https://github-staging.netflix.net/api/v3/users/corp/starred{/owner}{/repo}", - "subscriptions_url": "https://github-staging.netflix.net/api/v3/users/corp/subscriptions", - "organizations_url": "https://github-staging.netflix.net/api/v3/users/corp/orgs", - "repos_url": "https://github-staging.netflix.net/api/v3/users/corp/repos", - "events_url": "https://github-staging.netflix.net/api/v3/users/corp/events{/privacy}", - "received_events_url": "https://github-staging.netflix.net/api/v3/users/corp/received_events", + "url": "https://api.github.com/users/EJG-Organization", + "html_url": "https://github.com/EJG-Organization", + "followers_url": "https://api.github.com/users/EJG-Organization/followers", + "following_url": "https://api.github.com/users/EJG-Organization/following{/other_user}", + "gists_url": "https://api.github.com/users/EJG-Organization/gists{/gist_id}", + "starred_url": "https://api.github.com/users/EJG-Organization/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/EJG-Organization/subscriptions", + "organizations_url": "https://api.github.com/users/EJG-Organization/orgs", + "repos_url": "https://api.github.com/users/EJG-Organization/repos", + "events_url": "https://api.github.com/users/EJG-Organization/events{/privacy}", + "received_events_url": "https://api.github.com/users/EJG-Organization/received_events", "type": "Organization", "site_admin": false }, - "html_url": "https://github-staging.netflix.net/corp/egoh-test-repo-0", + "html_url": "https://github.com/EJG-Organization/react-workshop-renamed", "description": null, - "fork": false, - "url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0", - "forks_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/forks", - "keys_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/keys{/key_id}", - "collaborators_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/collaborators{/collaborator}", - "teams_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/teams", - "hooks_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/hooks", - "issue_events_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/issues/events{/number}", - "events_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/events", - "assignees_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/assignees{/user}", - "branches_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/branches{/branch}", - "tags_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/tags", - "blobs_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/git/blobs{/sha}", - "git_tags_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/git/tags{/sha}", - "git_refs_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/git/refs{/sha}", - "trees_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/git/trees{/sha}", - "statuses_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/statuses/{sha}", - "languages_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/languages", - "stargazers_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/stargazers", - "contributors_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/contributors", - "subscribers_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/subscribers", - "subscription_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/subscription", - "commits_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/commits{/sha}", - "git_commits_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/git/commits{/sha}", - "comments_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/comments{/number}", - "issue_comment_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/issues/comments{/number}", - "contents_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/contents/{+path}", - "compare_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/compare/{base}...{head}", - "merges_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/merges", - "archive_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/{archive_format}{/ref}", - "downloads_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/downloads", - "issues_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/issues{/number}", - "pulls_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/pulls{/number}", - "milestones_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/milestones{/number}", - "notifications_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/notifications{?since,all,participating}", - "labels_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/labels{/name}", - "releases_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/releases{/id}", - "deployments_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/deployments", - "created_at": "2024-04-19T21:42:10Z", - "updated_at": "2024-04-19T21:52:25Z", - "pushed_at": "2024-04-19T21:42:12Z", - "git_url": "git://github-staging.netflix.net/corp/egoh-test-repo-0.git", - "ssh_url": "git@github-staging.netflix.net:corp/egoh-test-repo-0.git", - "clone_url": "https://github-staging.netflix.net/corp/egoh-test-repo-0.git", - "svn_url": "https://github-staging.netflix.net/corp/egoh-test-repo-0", + "fork": true, + "url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed", + "forks_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/forks", + "keys_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/teams", + "hooks_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/hooks", + "issue_events_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/issues/events{/number}", + "events_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/events", + "assignees_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/assignees{/user}", + "branches_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/branches{/branch}", + "tags_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/tags", + "blobs_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/statuses/{sha}", + "languages_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/languages", + "stargazers_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/stargazers", + "contributors_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/contributors", + "subscribers_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/subscribers", + "subscription_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/subscription", + "commits_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/contents/{+path}", + "compare_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/merges", + "archive_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/downloads", + "issues_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/issues{/number}", + "pulls_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/pulls{/number}", + "milestones_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/milestones{/number}", + "notifications_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/labels{/name}", + "releases_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/releases{/id}", + "deployments_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/deployments", + "created_at": "2021-04-21T22:09:16Z", + "updated_at": "2024-04-25T20:31:00Z", + "pushed_at": "2021-04-21T03:47:44Z", + "git_url": "git://github.com/EJG-Organization/react-workshop-renamed.git", + "ssh_url": "git@github.com:EJG-Organization/react-workshop-renamed.git", + "clone_url": "https://github.com/EJG-Organization/react-workshop-renamed.git", + "svn_url": "https://github.com/EJG-Organization/react-workshop-renamed", "homepage": null, - "size": 0, + "size": 196, "stargazers_count": 0, "watchers_count": 0, "language": null, - "has_issues": true, + "has_issues": false, "has_projects": true, "has_downloads": true, "has_wiki": true, @@ -103,56 +103,47 @@ "topics": [ ], - "visibility": "internal", + "visibility": "public", "forks": 0, "open_issues": 0, "watchers": 0, - "default_branch": "main" + "default_branch": "main", + "custom_properties": { + + } }, "organization": { - "login": "corp", - "id": 5, - "node_id": "MDEyOk9yZ2FuaXphdGlvbjU=", - "url": "https://github-staging.netflix.net/api/v3/orgs/corp", - "repos_url": "https://github-staging.netflix.net/api/v3/orgs/corp/repos", - "events_url": "https://github-staging.netflix.net/api/v3/orgs/corp/events", - "hooks_url": "https://github-staging.netflix.net/api/v3/orgs/corp/hooks", - "issues_url": "https://github-staging.netflix.net/api/v3/orgs/corp/issues", - "members_url": "https://github-staging.netflix.net/api/v3/orgs/corp/members{/member}", - "public_members_url": "https://github-staging.netflix.net/api/v3/orgs/corp/public_members{/member}", - "avatar_url": "https://github-staging.netflix.net/avatars/u/5?", + "login": "EJG-Organization", + "id": 168135412, + "node_id": "O_kgDOCgWK9A", + "url": "https://api.github.com/orgs/EJG-Organization", + "repos_url": "https://api.github.com/orgs/EJG-Organization/repos", + "events_url": "https://api.github.com/orgs/EJG-Organization/events", + "hooks_url": "https://api.github.com/orgs/EJG-Organization/hooks", + "issues_url": "https://api.github.com/orgs/EJG-Organization/issues", + "members_url": "https://api.github.com/orgs/EJG-Organization/members{/member}", + "public_members_url": "https://api.github.com/orgs/EJG-Organization/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/168135412?v=4", "description": null }, - "enterprise": { - "id": 1, - "slug": "netflix", - "name": "Netflix", - "node_id": "MDEwOkVudGVycHJpc2Ux", - "avatar_url": "https://github-staging.netflix.net/avatars/b/1?", - "description": null, - "website_url": null, - "html_url": "https://github-staging.netflix.net/enterprises/netflix", - "created_at": "2023-10-12T06:56:57Z", - "updated_at": "2023-11-08T18:37:49Z" - }, "sender": { - "login": "egoh", - "id": 30, - "node_id": "MDQ6VXNlcjMw", - "avatar_url": "https://github-staging.netflix.net/avatars/u/30?", + "login": "eleanorgoh", + "id": 66235606, + "node_id": "MDQ6VXNlcjY2MjM1NjA2", + "avatar_url": "https://avatars.githubusercontent.com/u/66235606?v=4", "gravatar_id": "", - "url": "https://github-staging.netflix.net/api/v3/users/egoh", - "html_url": "https://github-staging.netflix.net/egoh", - "followers_url": "https://github-staging.netflix.net/api/v3/users/egoh/followers", - "following_url": "https://github-staging.netflix.net/api/v3/users/egoh/following{/other_user}", - "gists_url": "https://github-staging.netflix.net/api/v3/users/egoh/gists{/gist_id}", - "starred_url": "https://github-staging.netflix.net/api/v3/users/egoh/starred{/owner}{/repo}", - "subscriptions_url": "https://github-staging.netflix.net/api/v3/users/egoh/subscriptions", - "organizations_url": "https://github-staging.netflix.net/api/v3/users/egoh/orgs", - "repos_url": "https://github-staging.netflix.net/api/v3/users/egoh/repos", - "events_url": "https://github-staging.netflix.net/api/v3/users/egoh/events{/privacy}", - "received_events_url": "https://github-staging.netflix.net/api/v3/users/egoh/received_events", + "url": "https://api.github.com/users/eleanorgoh", + "html_url": "https://github.com/eleanorgoh", + "followers_url": "https://api.github.com/users/eleanorgoh/followers", + "following_url": "https://api.github.com/users/eleanorgoh/following{/other_user}", + "gists_url": "https://api.github.com/users/eleanorgoh/gists{/gist_id}", + "starred_url": "https://api.github.com/users/eleanorgoh/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/eleanorgoh/subscriptions", + "organizations_url": "https://api.github.com/users/eleanorgoh/orgs", + "repos_url": "https://api.github.com/users/eleanorgoh/repos", + "events_url": "https://api.github.com/users/eleanorgoh/events{/privacy}", + "received_events_url": "https://api.github.com/users/eleanorgoh/received_events", "type": "User", - "site_admin": true + "site_admin": false } } \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_transferred.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_transferred.json deleted file mode 100644 index 96e53a15b..000000000 --- a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_transferred.json +++ /dev/null @@ -1,177 +0,0 @@ -{ - "action": "transferred", - "changes": { - "owner": { - "from": { - "user": { - "login": "egoh", - "id": 30, - "node_id": "MDQ6VXNlcjMw", - "avatar_url": "https://github-staging.netflix.net/avatars/u/30?", - "gravatar_id": "", - "url": "https://github-staging.netflix.net/api/v3/users/egoh", - "html_url": "https://github-staging.netflix.net/egoh", - "followers_url": "https://github-staging.netflix.net/api/v3/users/egoh/followers", - "following_url": "https://github-staging.netflix.net/api/v3/users/egoh/following{/other_user}", - "gists_url": "https://github-staging.netflix.net/api/v3/users/egoh/gists{/gist_id}", - "starred_url": "https://github-staging.netflix.net/api/v3/users/egoh/starred{/owner}{/repo}", - "subscriptions_url": "https://github-staging.netflix.net/api/v3/users/egoh/subscriptions", - "organizations_url": "https://github-staging.netflix.net/api/v3/users/egoh/orgs", - "repos_url": "https://github-staging.netflix.net/api/v3/users/egoh/repos", - "events_url": "https://github-staging.netflix.net/api/v3/users/egoh/events{/privacy}", - "received_events_url": "https://github-staging.netflix.net/api/v3/users/egoh/received_events", - "type": "User", - "site_admin": true - } - } - } - }, - "repository": { - "id": 52124, - "node_id": "MDEwOlJlcG9zaXRvcnk1MjEyNA==", - "name": "egoh-test-repo-2", - "full_name": "corp/egoh-test-repo-2", - "private": false, - "owner": { - "login": "corp", - "id": 5, - "node_id": "MDEyOk9yZ2FuaXphdGlvbjU=", - "avatar_url": "https://github-staging.netflix.net/avatars/u/5?", - "gravatar_id": "", - "url": "https://github-staging.netflix.net/api/v3/users/corp", - "html_url": "https://github-staging.netflix.net/corp", - "followers_url": "https://github-staging.netflix.net/api/v3/users/corp/followers", - "following_url": "https://github-staging.netflix.net/api/v3/users/corp/following{/other_user}", - "gists_url": "https://github-staging.netflix.net/api/v3/users/corp/gists{/gist_id}", - "starred_url": "https://github-staging.netflix.net/api/v3/users/corp/starred{/owner}{/repo}", - "subscriptions_url": "https://github-staging.netflix.net/api/v3/users/corp/subscriptions", - "organizations_url": "https://github-staging.netflix.net/api/v3/users/corp/orgs", - "repos_url": "https://github-staging.netflix.net/api/v3/users/corp/repos", - "events_url": "https://github-staging.netflix.net/api/v3/users/corp/events{/privacy}", - "received_events_url": "https://github-staging.netflix.net/api/v3/users/corp/received_events", - "type": "Organization", - "site_admin": false - }, - "html_url": "https://github-staging.netflix.net/corp/egoh-test-repo-2", - "description": null, - "fork": false, - "url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2", - "forks_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/forks", - "keys_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/keys{/key_id}", - "collaborators_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/collaborators{/collaborator}", - "teams_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/teams", - "hooks_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/hooks", - "issue_events_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/issues/events{/number}", - "events_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/events", - "assignees_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/assignees{/user}", - "branches_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/branches{/branch}", - "tags_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/tags", - "blobs_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/git/blobs{/sha}", - "git_tags_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/git/tags{/sha}", - "git_refs_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/git/refs{/sha}", - "trees_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/git/trees{/sha}", - "statuses_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/statuses/{sha}", - "languages_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/languages", - "stargazers_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/stargazers", - "contributors_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/contributors", - "subscribers_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/subscribers", - "subscription_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/subscription", - "commits_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/commits{/sha}", - "git_commits_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/git/commits{/sha}", - "comments_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/comments{/number}", - "issue_comment_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/issues/comments{/number}", - "contents_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/contents/{+path}", - "compare_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/compare/{base}...{head}", - "merges_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/merges", - "archive_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/{archive_format}{/ref}", - "downloads_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/downloads", - "issues_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/issues{/number}", - "pulls_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/pulls{/number}", - "milestones_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/milestones{/number}", - "notifications_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/notifications{?since,all,participating}", - "labels_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/labels{/name}", - "releases_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/releases{/id}", - "deployments_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-2/deployments", - "created_at": "2024-04-19T21:47:45Z", - "updated_at": "2024-04-19T21:48:07Z", - "pushed_at": "2024-04-19T21:47:46Z", - "git_url": "git://github-staging.netflix.net/corp/egoh-test-repo-2.git", - "ssh_url": "git@github-staging.netflix.net:corp/egoh-test-repo-2.git", - "clone_url": "https://github-staging.netflix.net/corp/egoh-test-repo-2.git", - "svn_url": "https://github-staging.netflix.net/corp/egoh-test-repo-2", - "homepage": null, - "size": 0, - "stargazers_count": 0, - "watchers_count": 0, - "language": null, - "has_issues": true, - "has_projects": true, - "has_downloads": true, - "has_wiki": true, - "has_pages": false, - "has_discussions": false, - "forks_count": 0, - "mirror_url": null, - "archived": false, - "disabled": false, - "open_issues_count": 0, - "license": null, - "allow_forking": true, - "is_template": false, - "web_commit_signoff_required": false, - "topics": [ - - ], - "visibility": "public", - "forks": 0, - "open_issues": 0, - "watchers": 0, - "default_branch": "main" - }, - "organization": { - "login": "corp", - "id": 5, - "node_id": "MDEyOk9yZ2FuaXphdGlvbjU=", - "url": "https://github-staging.netflix.net/api/v3/orgs/corp", - "repos_url": "https://github-staging.netflix.net/api/v3/orgs/corp/repos", - "events_url": "https://github-staging.netflix.net/api/v3/orgs/corp/events", - "hooks_url": "https://github-staging.netflix.net/api/v3/orgs/corp/hooks", - "issues_url": "https://github-staging.netflix.net/api/v3/orgs/corp/issues", - "members_url": "https://github-staging.netflix.net/api/v3/orgs/corp/members{/member}", - "public_members_url": "https://github-staging.netflix.net/api/v3/orgs/corp/public_members{/member}", - "avatar_url": "https://github-staging.netflix.net/avatars/u/5?", - "description": null - }, - "enterprise": { - "id": 1, - "slug": "netflix", - "name": "Netflix", - "node_id": "MDEwOkVudGVycHJpc2Ux", - "avatar_url": "https://github-staging.netflix.net/avatars/b/1?", - "description": null, - "website_url": null, - "html_url": "https://github-staging.netflix.net/enterprises/netflix", - "created_at": "2023-10-12T06:56:57Z", - "updated_at": "2023-11-08T18:37:49Z" - }, - "sender": { - "login": "egoh", - "id": 30, - "node_id": "MDQ6VXNlcjMw", - "avatar_url": "https://github-staging.netflix.net/avatars/u/30?", - "gravatar_id": "", - "url": "https://github-staging.netflix.net/api/v3/users/egoh", - "html_url": "https://github-staging.netflix.net/egoh", - "followers_url": "https://github-staging.netflix.net/api/v3/users/egoh/followers", - "following_url": "https://github-staging.netflix.net/api/v3/users/egoh/following{/other_user}", - "gists_url": "https://github-staging.netflix.net/api/v3/users/egoh/gists{/gist_id}", - "starred_url": "https://github-staging.netflix.net/api/v3/users/egoh/starred{/owner}{/repo}", - "subscriptions_url": "https://github-staging.netflix.net/api/v3/users/egoh/subscriptions", - "organizations_url": "https://github-staging.netflix.net/api/v3/users/egoh/orgs", - "repos_url": "https://github-staging.netflix.net/api/v3/users/egoh/repos", - "events_url": "https://github-staging.netflix.net/api/v3/users/egoh/events{/privacy}", - "received_events_url": "https://github-staging.netflix.net/api/v3/users/egoh/received_events", - "type": "User", - "site_admin": true - } -} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_transferred_to_org.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_transferred_to_org.json new file mode 100644 index 000000000..2e5814818 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_transferred_to_org.json @@ -0,0 +1,168 @@ +{ + "action": "transferred", + "changes": { + "owner": { + "from": { + "user": { + "login": "eleanorgoh", + "id": 66235606, + "node_id": "MDQ6VXNlcjY2MjM1NjA2", + "avatar_url": "https://avatars.githubusercontent.com/u/66235606?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/eleanorgoh", + "html_url": "https://github.com/eleanorgoh", + "followers_url": "https://api.github.com/users/eleanorgoh/followers", + "following_url": "https://api.github.com/users/eleanorgoh/following{/other_user}", + "gists_url": "https://api.github.com/users/eleanorgoh/gists{/gist_id}", + "starred_url": "https://api.github.com/users/eleanorgoh/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/eleanorgoh/subscriptions", + "organizations_url": "https://api.github.com/users/eleanorgoh/orgs", + "repos_url": "https://api.github.com/users/eleanorgoh/repos", + "events_url": "https://api.github.com/users/eleanorgoh/events{/privacy}", + "received_events_url": "https://api.github.com/users/eleanorgoh/received_events", + "type": "User", + "site_admin": false + } + } + } + }, + "repository": { + "id": 360319037, + "node_id": "MDEwOlJlcG9zaXRvcnkzNjAzMTkwMzc=", + "name": "react-workshop", + "full_name": "EJG-Organization/react-workshop", + "private": false, + "owner": { + "login": "EJG-Organization", + "id": 168135412, + "node_id": "O_kgDOCgWK9A", + "avatar_url": "https://avatars.githubusercontent.com/u/168135412?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/EJG-Organization", + "html_url": "https://github.com/EJG-Organization", + "followers_url": "https://api.github.com/users/EJG-Organization/followers", + "following_url": "https://api.github.com/users/EJG-Organization/following{/other_user}", + "gists_url": "https://api.github.com/users/EJG-Organization/gists{/gist_id}", + "starred_url": "https://api.github.com/users/EJG-Organization/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/EJG-Organization/subscriptions", + "organizations_url": "https://api.github.com/users/EJG-Organization/orgs", + "repos_url": "https://api.github.com/users/EJG-Organization/repos", + "events_url": "https://api.github.com/users/EJG-Organization/events{/privacy}", + "received_events_url": "https://api.github.com/users/EJG-Organization/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/EJG-Organization/react-workshop", + "description": null, + "fork": true, + "url": "https://api.github.com/repos/EJG-Organization/react-workshop", + "forks_url": "https://api.github.com/repos/EJG-Organization/react-workshop/forks", + "keys_url": "https://api.github.com/repos/EJG-Organization/react-workshop/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/EJG-Organization/react-workshop/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/EJG-Organization/react-workshop/teams", + "hooks_url": "https://api.github.com/repos/EJG-Organization/react-workshop/hooks", + "issue_events_url": "https://api.github.com/repos/EJG-Organization/react-workshop/issues/events{/number}", + "events_url": "https://api.github.com/repos/EJG-Organization/react-workshop/events", + "assignees_url": "https://api.github.com/repos/EJG-Organization/react-workshop/assignees{/user}", + "branches_url": "https://api.github.com/repos/EJG-Organization/react-workshop/branches{/branch}", + "tags_url": "https://api.github.com/repos/EJG-Organization/react-workshop/tags", + "blobs_url": "https://api.github.com/repos/EJG-Organization/react-workshop/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/EJG-Organization/react-workshop/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/EJG-Organization/react-workshop/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/EJG-Organization/react-workshop/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/EJG-Organization/react-workshop/statuses/{sha}", + "languages_url": "https://api.github.com/repos/EJG-Organization/react-workshop/languages", + "stargazers_url": "https://api.github.com/repos/EJG-Organization/react-workshop/stargazers", + "contributors_url": "https://api.github.com/repos/EJG-Organization/react-workshop/contributors", + "subscribers_url": "https://api.github.com/repos/EJG-Organization/react-workshop/subscribers", + "subscription_url": "https://api.github.com/repos/EJG-Organization/react-workshop/subscription", + "commits_url": "https://api.github.com/repos/EJG-Organization/react-workshop/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/EJG-Organization/react-workshop/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/EJG-Organization/react-workshop/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/EJG-Organization/react-workshop/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/EJG-Organization/react-workshop/contents/{+path}", + "compare_url": "https://api.github.com/repos/EJG-Organization/react-workshop/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/EJG-Organization/react-workshop/merges", + "archive_url": "https://api.github.com/repos/EJG-Organization/react-workshop/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/EJG-Organization/react-workshop/downloads", + "issues_url": "https://api.github.com/repos/EJG-Organization/react-workshop/issues{/number}", + "pulls_url": "https://api.github.com/repos/EJG-Organization/react-workshop/pulls{/number}", + "milestones_url": "https://api.github.com/repos/EJG-Organization/react-workshop/milestones{/number}", + "notifications_url": "https://api.github.com/repos/EJG-Organization/react-workshop/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/EJG-Organization/react-workshop/labels{/name}", + "releases_url": "https://api.github.com/repos/EJG-Organization/react-workshop/releases{/id}", + "deployments_url": "https://api.github.com/repos/EJG-Organization/react-workshop/deployments", + "created_at": "2021-04-21T22:09:16Z", + "updated_at": "2024-04-25T20:28:46Z", + "pushed_at": "2021-04-21T03:47:44Z", + "git_url": "git://github.com/EJG-Organization/react-workshop.git", + "ssh_url": "git@github.com:EJG-Organization/react-workshop.git", + "clone_url": "https://github.com/EJG-Organization/react-workshop.git", + "svn_url": "https://github.com/EJG-Organization/react-workshop", + "homepage": null, + "size": 196, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + + ], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main", + "custom_properties": { + + } + }, + "organization": { + "login": "EJG-Organization", + "id": 168135412, + "node_id": "O_kgDOCgWK9A", + "url": "https://api.github.com/orgs/EJG-Organization", + "repos_url": "https://api.github.com/orgs/EJG-Organization/repos", + "events_url": "https://api.github.com/orgs/EJG-Organization/events", + "hooks_url": "https://api.github.com/orgs/EJG-Organization/hooks", + "issues_url": "https://api.github.com/orgs/EJG-Organization/issues", + "members_url": "https://api.github.com/orgs/EJG-Organization/members{/member}", + "public_members_url": "https://api.github.com/orgs/EJG-Organization/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/168135412?v=4", + "description": null + }, + "sender": { + "login": "eleanorgoh", + "id": 66235606, + "node_id": "MDQ6VXNlcjY2MjM1NjA2", + "avatar_url": "https://avatars.githubusercontent.com/u/66235606?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/eleanorgoh", + "html_url": "https://github.com/eleanorgoh", + "followers_url": "https://api.github.com/users/eleanorgoh/followers", + "following_url": "https://api.github.com/users/eleanorgoh/following{/other_user}", + "gists_url": "https://api.github.com/users/eleanorgoh/gists{/gist_id}", + "starred_url": "https://api.github.com/users/eleanorgoh/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/eleanorgoh/subscriptions", + "organizations_url": "https://api.github.com/users/eleanorgoh/orgs", + "repos_url": "https://api.github.com/users/eleanorgoh/repos", + "events_url": "https://api.github.com/users/eleanorgoh/events{/privacy}", + "received_events_url": "https://api.github.com/users/eleanorgoh/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_transferred_to_user.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_transferred_to_user.json new file mode 100644 index 000000000..57fbd5502 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/repository_transferred_to_user.json @@ -0,0 +1,145 @@ +{ + "action": "transferred", + "changes": { + "owner": { + "from": { + "organization": { + "login": "EJG-Organization", + "id": 168135412, + "node_id": "O_kgDOCgWK9A", + "url": "https://api.github.com/orgs/EJG-Organization", + "repos_url": "https://api.github.com/orgs/EJG-Organization/repos", + "events_url": "https://api.github.com/orgs/EJG-Organization/events", + "hooks_url": "https://api.github.com/orgs/EJG-Organization/hooks", + "issues_url": "https://api.github.com/orgs/EJG-Organization/issues", + "members_url": "https://api.github.com/orgs/EJG-Organization/members{/member}", + "public_members_url": "https://api.github.com/orgs/EJG-Organization/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/168135412?v=4", + "description": null + } + } + } + }, + "repository": { + "id": 360319037, + "node_id": "MDEwOlJlcG9zaXRvcnkzNjAzMTkwMzc=", + "name": "react-workshop-renamed", + "full_name": "eleanorgoh/react-workshop-renamed", + "private": false, + "owner": { + "login": "eleanorgoh", + "id": 66235606, + "node_id": "MDQ6VXNlcjY2MjM1NjA2", + "avatar_url": "https://avatars.githubusercontent.com/u/66235606?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/eleanorgoh", + "html_url": "https://github.com/eleanorgoh", + "followers_url": "https://api.github.com/users/eleanorgoh/followers", + "following_url": "https://api.github.com/users/eleanorgoh/following{/other_user}", + "gists_url": "https://api.github.com/users/eleanorgoh/gists{/gist_id}", + "starred_url": "https://api.github.com/users/eleanorgoh/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/eleanorgoh/subscriptions", + "organizations_url": "https://api.github.com/users/eleanorgoh/orgs", + "repos_url": "https://api.github.com/users/eleanorgoh/repos", + "events_url": "https://api.github.com/users/eleanorgoh/events{/privacy}", + "received_events_url": "https://api.github.com/users/eleanorgoh/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/eleanorgoh/react-workshop-renamed", + "description": null, + "fork": true, + "url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed", + "forks_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/forks", + "keys_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/teams", + "hooks_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/hooks", + "issue_events_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/issues/events{/number}", + "events_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/events", + "assignees_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/assignees{/user}", + "branches_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/branches{/branch}", + "tags_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/tags", + "blobs_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/statuses/{sha}", + "languages_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/languages", + "stargazers_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/stargazers", + "contributors_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/contributors", + "subscribers_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/subscribers", + "subscription_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/subscription", + "commits_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/contents/{+path}", + "compare_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/merges", + "archive_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/downloads", + "issues_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/issues{/number}", + "pulls_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/pulls{/number}", + "milestones_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/milestones{/number}", + "notifications_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/labels{/name}", + "releases_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/releases{/id}", + "deployments_url": "https://api.github.com/repos/eleanorgoh/react-workshop-renamed/deployments", + "created_at": "2021-04-21T22:09:16Z", + "updated_at": "2024-04-25T20:36:56Z", + "pushed_at": "2021-04-21T03:47:44Z", + "git_url": "git://github.com/eleanorgoh/react-workshop-renamed.git", + "ssh_url": "git@github.com:eleanorgoh/react-workshop-renamed.git", + "clone_url": "https://github.com/eleanorgoh/react-workshop-renamed.git", + "svn_url": "https://github.com/eleanorgoh/react-workshop-renamed", + "homepage": null, + "size": 196, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + + ], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main" + }, + "sender": { + "login": "eleanorgoh", + "id": 66235606, + "node_id": "MDQ6VXNlcjY2MjM1NjA2", + "avatar_url": "https://avatars.githubusercontent.com/u/66235606?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/eleanorgoh", + "html_url": "https://github.com/eleanorgoh", + "followers_url": "https://api.github.com/users/eleanorgoh/followers", + "following_url": "https://api.github.com/users/eleanorgoh/following{/other_user}", + "gists_url": "https://api.github.com/users/eleanorgoh/gists{/gist_id}", + "starred_url": "https://api.github.com/users/eleanorgoh/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/eleanorgoh/subscriptions", + "organizations_url": "https://api.github.com/users/eleanorgoh/orgs", + "repos_url": "https://api.github.com/users/eleanorgoh/repos", + "events_url": "https://api.github.com/users/eleanorgoh/events{/privacy}", + "received_events_url": "https://api.github.com/users/eleanorgoh/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file From c5ce1f60813804da3bb6eb32b16967226d34b9f8 Mon Sep 17 00:00:00 2001 From: Eleanor Goh Date: Fri, 26 Apr 2024 12:38:05 -0700 Subject: [PATCH 5/5] Move GHRepositoryChanges under Repository class --- src/main/java/org/kohsuke/github/GHEventPayload.java | 12 +----------- .../java/org/kohsuke/github/GHEventPayloadTest.java | 12 ++++++------ 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHEventPayload.java b/src/main/java/org/kohsuke/github/GHEventPayload.java index 965b51b77..2e34daa29 100644 --- a/src/main/java/org/kohsuke/github/GHEventPayload.java +++ b/src/main/java/org/kohsuke/github/GHEventPayload.java @@ -1445,17 +1445,6 @@ public void setRelease(GHRelease release) { * @see Repositories */ public static class Repository extends GHEventPayload { - - } - - /** - * A repository was renamed or transferred. - * - * @see - * repository event - * @see Repositories - */ - public static class RepositoryChanges extends GHEventPayload { private GHRepositoryChanges changes; /** @@ -1466,6 +1455,7 @@ public static class RepositoryChanges extends GHEventPayload { public GHRepositoryChanges getChanges() { return changes; } + } /** diff --git a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java index 212066d5a..1e1513c2e 100644 --- a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java +++ b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java @@ -780,8 +780,8 @@ public void repository() throws Exception { */ @Test public void repository_renamed() throws Exception { - final GHEventPayload.RepositoryChanges event = GitHub.offline() - .parseEventPayload(payload.asReader(), GHEventPayload.RepositoryChanges.class); + final GHEventPayload.Repository event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Repository.class); assertThat(event.getAction(), is("renamed")); assertThat(event.getChanges().getRepository().getName().getFrom(), is("react-workshop")); assertThat(event.getRepository().getName(), is("react-workshop-renamed")); @@ -798,8 +798,8 @@ public void repository_renamed() throws Exception { */ @Test public void repository_transferred_to_org() throws Exception { - final GHEventPayload.RepositoryChanges event = GitHub.offline() - .parseEventPayload(payload.asReader(), GHEventPayload.RepositoryChanges.class); + final GHEventPayload.Repository event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Repository.class); assertThat(event.getAction(), is("transferred")); assertThat(event.getChanges().getOwner().getFrom().getUser().getLogin(), is("eleanorgoh")); assertThat(event.getChanges().getOwner().getFrom().getUser().getId(), is(66235606L)); @@ -814,8 +814,8 @@ public void repository_transferred_to_org() throws Exception { */ @Test public void repository_transferred_to_user() throws Exception { - final GHEventPayload.RepositoryChanges event = GitHub.offline() - .parseEventPayload(payload.asReader(), GHEventPayload.RepositoryChanges.class); + final GHEventPayload.Repository event = GitHub.offline() + .parseEventPayload(payload.asReader(), GHEventPayload.Repository.class); assertThat(event.getAction(), is("transferred")); assertThat(event.getChanges().getOwner().getFrom().getOrganization().getLogin(), is("EJG-Organization")); assertThat(event.getChanges().getOwner().getFrom().getOrganization().getId(), is(168135412L));