Skip to content

Commit ea025b5

Browse files
authored
Merge branch 'main' into patch-1
2 parents 793b277 + 2e6dcc1 commit ea025b5

File tree

6 files changed

+629
-0
lines changed

6 files changed

+629
-0
lines changed

src/main/java/org/kohsuke/github/GHEventPayload.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,16 @@ public void setRelease(GHRelease release) {
14451445
* @see <a href="https://docs.github.com/en/rest/reference/repos">Repositories</a>
14461446
*/
14471447
public static class Repository extends GHEventPayload {
1448+
private GHRepositoryChanges changes;
1449+
1450+
/**
1451+
* Get changes.
1452+
*
1453+
* @return GHRepositoryChanges
1454+
*/
1455+
public GHRepositoryChanges getChanges() {
1456+
return changes;
1457+
}
14481458

14491459
}
14501460

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package org.kohsuke.github;
2+
3+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4+
5+
/**
6+
* Changes made to a repository.
7+
*/
8+
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
9+
public class GHRepositoryChanges {
10+
private FromRepository repository;
11+
private Owner owner;
12+
13+
/**
14+
* Get outer owner object.
15+
*
16+
* @return Owner
17+
*/
18+
public Owner getOwner() {
19+
return owner;
20+
}
21+
22+
/**
23+
* Outer object of owner from whom this repository was transferred.
24+
*/
25+
public static class Owner {
26+
private FromOwner from;
27+
28+
/**
29+
* Get in owner object.
30+
*
31+
* @return FromOwner
32+
*/
33+
public FromOwner getFrom() {
34+
return from;
35+
}
36+
}
37+
38+
/**
39+
* Owner from whom this repository was transferred.
40+
*/
41+
public static class FromOwner {
42+
private GHUser user;
43+
private GHOrganization organization;
44+
45+
/**
46+
* Get user from which this repository was transferred.
47+
*
48+
* @return user
49+
*/
50+
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
51+
public GHUser getUser() {
52+
return user;
53+
}
54+
55+
/**
56+
* Get organization from which this repository was transferred.
57+
*
58+
* @return GHOrganization
59+
*/
60+
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected")
61+
public GHOrganization getOrganization() {
62+
return organization;
63+
}
64+
}
65+
66+
/**
67+
* Get repository.
68+
*
69+
* @return FromRepository
70+
*/
71+
public FromRepository getRepository() {
72+
return repository;
73+
}
74+
75+
/**
76+
* Repository object from which the name was changed.
77+
*/
78+
public static class FromRepository {
79+
private FromName name;
80+
81+
/**
82+
* Get top level object for the previous name of the repository.
83+
*
84+
* @return FromName
85+
*/
86+
public FromName getName() {
87+
return name;
88+
}
89+
}
90+
91+
/**
92+
* Repository name that was changed.
93+
*/
94+
public static class FromName {
95+
private String from;
96+
97+
/**
98+
* Get previous name of the repository before rename.
99+
*
100+
* @return String
101+
*/
102+
public String getFrom() {
103+
return from;
104+
}
105+
}
106+
}

src/test/java/org/kohsuke/github/GHEventPayloadTest.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,57 @@ public void repository() throws Exception {
772772
assertThat(event.getSender().getLogin(), is("baxterthehacker"));
773773
}
774774

775+
/**
776+
* Repository renamed.
777+
*
778+
* @throws Exception
779+
* the exception
780+
*/
781+
@Test
782+
public void repository_renamed() throws Exception {
783+
final GHEventPayload.Repository event = GitHub.offline()
784+
.parseEventPayload(payload.asReader(), GHEventPayload.Repository.class);
785+
assertThat(event.getAction(), is("renamed"));
786+
assertThat(event.getChanges().getRepository().getName().getFrom(), is("react-workshop"));
787+
assertThat(event.getRepository().getName(), is("react-workshop-renamed"));
788+
assertThat(event.getRepository().getOwner().getLogin(), is("EJG-Organization"));
789+
assertThat(event.getOrganization().getLogin(), is("EJG-Organization"));
790+
assertThat(event.getSender().getLogin(), is("eleanorgoh"));
791+
}
792+
793+
/**
794+
* Repository ownership transferred to an organization.
795+
*
796+
* @throws Exception
797+
* the exception
798+
*/
799+
@Test
800+
public void repository_transferred_to_org() throws Exception {
801+
final GHEventPayload.Repository event = GitHub.offline()
802+
.parseEventPayload(payload.asReader(), GHEventPayload.Repository.class);
803+
assertThat(event.getAction(), is("transferred"));
804+
assertThat(event.getChanges().getOwner().getFrom().getUser().getLogin(), is("eleanorgoh"));
805+
assertThat(event.getChanges().getOwner().getFrom().getUser().getId(), is(66235606L));
806+
assertThat(event.getChanges().getOwner().getFrom().getUser().getType(), is("User"));
807+
}
808+
809+
/**
810+
* Repository ownership transferred to a user.
811+
*
812+
* @throws Exception
813+
* the exception
814+
*/
815+
@Test
816+
public void repository_transferred_to_user() throws Exception {
817+
final GHEventPayload.Repository event = GitHub.offline()
818+
.parseEventPayload(payload.asReader(), GHEventPayload.Repository.class);
819+
assertThat(event.getAction(), is("transferred"));
820+
assertThat(event.getChanges().getOwner().getFrom().getOrganization().getLogin(), is("EJG-Organization"));
821+
assertThat(event.getChanges().getOwner().getFrom().getOrganization().getId(), is(168135412L));
822+
assertThat(event.getRepository().getOwner().getLogin(), is("eleanorgoh"));
823+
assertThat(event.getRepository().getOwner().getType(), is("User"));
824+
}
825+
775826
/**
776827
* Status.
777828
*
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
{
2+
"action": "renamed",
3+
"changes": {
4+
"repository": {
5+
"name": {
6+
"from": "react-workshop"
7+
}
8+
}
9+
},
10+
"repository": {
11+
"id": 360319037,
12+
"node_id": "MDEwOlJlcG9zaXRvcnkzNjAzMTkwMzc=",
13+
"name": "react-workshop-renamed",
14+
"full_name": "EJG-Organization/react-workshop-renamed",
15+
"private": false,
16+
"owner": {
17+
"login": "EJG-Organization",
18+
"id": 168135412,
19+
"node_id": "O_kgDOCgWK9A",
20+
"avatar_url": "https://avatars.githubusercontent.com/u/168135412?v=4",
21+
"gravatar_id": "",
22+
"url": "https://api.github.com/users/EJG-Organization",
23+
"html_url": "https://github.com/EJG-Organization",
24+
"followers_url": "https://api.github.com/users/EJG-Organization/followers",
25+
"following_url": "https://api.github.com/users/EJG-Organization/following{/other_user}",
26+
"gists_url": "https://api.github.com/users/EJG-Organization/gists{/gist_id}",
27+
"starred_url": "https://api.github.com/users/EJG-Organization/starred{/owner}{/repo}",
28+
"subscriptions_url": "https://api.github.com/users/EJG-Organization/subscriptions",
29+
"organizations_url": "https://api.github.com/users/EJG-Organization/orgs",
30+
"repos_url": "https://api.github.com/users/EJG-Organization/repos",
31+
"events_url": "https://api.github.com/users/EJG-Organization/events{/privacy}",
32+
"received_events_url": "https://api.github.com/users/EJG-Organization/received_events",
33+
"type": "Organization",
34+
"site_admin": false
35+
},
36+
"html_url": "https://github.com/EJG-Organization/react-workshop-renamed",
37+
"description": null,
38+
"fork": true,
39+
"url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed",
40+
"forks_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/forks",
41+
"keys_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/keys{/key_id}",
42+
"collaborators_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/collaborators{/collaborator}",
43+
"teams_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/teams",
44+
"hooks_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/hooks",
45+
"issue_events_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/issues/events{/number}",
46+
"events_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/events",
47+
"assignees_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/assignees{/user}",
48+
"branches_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/branches{/branch}",
49+
"tags_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/tags",
50+
"blobs_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/git/blobs{/sha}",
51+
"git_tags_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/git/tags{/sha}",
52+
"git_refs_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/git/refs{/sha}",
53+
"trees_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/git/trees{/sha}",
54+
"statuses_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/statuses/{sha}",
55+
"languages_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/languages",
56+
"stargazers_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/stargazers",
57+
"contributors_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/contributors",
58+
"subscribers_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/subscribers",
59+
"subscription_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/subscription",
60+
"commits_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/commits{/sha}",
61+
"git_commits_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/git/commits{/sha}",
62+
"comments_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/comments{/number}",
63+
"issue_comment_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/issues/comments{/number}",
64+
"contents_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/contents/{+path}",
65+
"compare_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/compare/{base}...{head}",
66+
"merges_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/merges",
67+
"archive_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/{archive_format}{/ref}",
68+
"downloads_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/downloads",
69+
"issues_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/issues{/number}",
70+
"pulls_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/pulls{/number}",
71+
"milestones_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/milestones{/number}",
72+
"notifications_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/notifications{?since,all,participating}",
73+
"labels_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/labels{/name}",
74+
"releases_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/releases{/id}",
75+
"deployments_url": "https://api.github.com/repos/EJG-Organization/react-workshop-renamed/deployments",
76+
"created_at": "2021-04-21T22:09:16Z",
77+
"updated_at": "2024-04-25T20:31:00Z",
78+
"pushed_at": "2021-04-21T03:47:44Z",
79+
"git_url": "git://github.com/EJG-Organization/react-workshop-renamed.git",
80+
"ssh_url": "git@github.com:EJG-Organization/react-workshop-renamed.git",
81+
"clone_url": "https://github.com/EJG-Organization/react-workshop-renamed.git",
82+
"svn_url": "https://github.com/EJG-Organization/react-workshop-renamed",
83+
"homepage": null,
84+
"size": 196,
85+
"stargazers_count": 0,
86+
"watchers_count": 0,
87+
"language": null,
88+
"has_issues": false,
89+
"has_projects": true,
90+
"has_downloads": true,
91+
"has_wiki": true,
92+
"has_pages": false,
93+
"has_discussions": false,
94+
"forks_count": 0,
95+
"mirror_url": null,
96+
"archived": false,
97+
"disabled": false,
98+
"open_issues_count": 0,
99+
"license": null,
100+
"allow_forking": true,
101+
"is_template": false,
102+
"web_commit_signoff_required": false,
103+
"topics": [
104+
105+
],
106+
"visibility": "public",
107+
"forks": 0,
108+
"open_issues": 0,
109+
"watchers": 0,
110+
"default_branch": "main",
111+
"custom_properties": {
112+
113+
}
114+
},
115+
"organization": {
116+
"login": "EJG-Organization",
117+
"id": 168135412,
118+
"node_id": "O_kgDOCgWK9A",
119+
"url": "https://api.github.com/orgs/EJG-Organization",
120+
"repos_url": "https://api.github.com/orgs/EJG-Organization/repos",
121+
"events_url": "https://api.github.com/orgs/EJG-Organization/events",
122+
"hooks_url": "https://api.github.com/orgs/EJG-Organization/hooks",
123+
"issues_url": "https://api.github.com/orgs/EJG-Organization/issues",
124+
"members_url": "https://api.github.com/orgs/EJG-Organization/members{/member}",
125+
"public_members_url": "https://api.github.com/orgs/EJG-Organization/public_members{/member}",
126+
"avatar_url": "https://avatars.githubusercontent.com/u/168135412?v=4",
127+
"description": null
128+
},
129+
"sender": {
130+
"login": "eleanorgoh",
131+
"id": 66235606,
132+
"node_id": "MDQ6VXNlcjY2MjM1NjA2",
133+
"avatar_url": "https://avatars.githubusercontent.com/u/66235606?v=4",
134+
"gravatar_id": "",
135+
"url": "https://api.github.com/users/eleanorgoh",
136+
"html_url": "https://github.com/eleanorgoh",
137+
"followers_url": "https://api.github.com/users/eleanorgoh/followers",
138+
"following_url": "https://api.github.com/users/eleanorgoh/following{/other_user}",
139+
"gists_url": "https://api.github.com/users/eleanorgoh/gists{/gist_id}",
140+
"starred_url": "https://api.github.com/users/eleanorgoh/starred{/owner}{/repo}",
141+
"subscriptions_url": "https://api.github.com/users/eleanorgoh/subscriptions",
142+
"organizations_url": "https://api.github.com/users/eleanorgoh/orgs",
143+
"repos_url": "https://api.github.com/users/eleanorgoh/repos",
144+
"events_url": "https://api.github.com/users/eleanorgoh/events{/privacy}",
145+
"received_events_url": "https://api.github.com/users/eleanorgoh/received_events",
146+
"type": "User",
147+
"site_admin": false
148+
}
149+
}

0 commit comments

Comments
 (0)