Skip to content

Commit 0dc3700

Browse files
committed
Repository Renamed event
1 parent 6b2a487 commit 0dc3700

File tree

3 files changed

+209
-0
lines changed

3 files changed

+209
-0
lines changed

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,45 @@ public static class Repository extends GHEventPayload {
14481448

14491449
}
14501450

1451+
/**
1452+
* A repository was renamed or transferred.
1453+
*
1454+
* @see <a href="https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#repository">
1455+
* repository event</a>
1456+
* @see <a href="https://docs.github.com/en/rest/reference/repos">Repositories</a>
1457+
*/
1458+
public static class RepositoryChanges extends GHEventPayload {
1459+
private GHRepositoryChanges changes;
1460+
1461+
public GHRepositoryChanges getChanges() {
1462+
return changes;
1463+
}
1464+
1465+
public static class GHRepositoryChanges {
1466+
private FromRepository repository;
1467+
1468+
public FromRepository getRepository() {
1469+
return repository;
1470+
}
1471+
1472+
public static class FromRepository {
1473+
private FromName name;
1474+
1475+
public FromName getName() {
1476+
return name;
1477+
}
1478+
}
1479+
1480+
public static class FromName {
1481+
private String from;
1482+
1483+
public String getFrom() {
1484+
return from;
1485+
}
1486+
}
1487+
}
1488+
}
1489+
14511490
/**
14521491
* A git commit status was changed.
14531492
*

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

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

775+
@Test
776+
public void repository_renamed() throws Exception {
777+
final GHEventPayload.RepositoryChanges event = GitHub.offline()
778+
.parseEventPayload(payload.asReader(), GHEventPayload.RepositoryChanges.class);
779+
assertThat(event.getAction(), is("renamed"));
780+
assertThat(event.getChanges().getRepository().getName().getFrom(), is("egoh-test-repo"));
781+
assertThat(event.getRepository().getName(), is("egoh-test-repo-0"));
782+
assertThat(event.getRepository().getOwner().getLogin(), is("corp"));
783+
assertThat(event.getOrganization().getLogin(), is("corp"));
784+
assertThat(event.getSender().getLogin(), is("egoh"));
785+
}
786+
775787
/**
776788
* Status.
777789
*
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
{
2+
"action": "renamed",
3+
"changes": {
4+
"repository": {
5+
"name": {
6+
"from": "egoh-test-repo"
7+
}
8+
}
9+
},
10+
"repository": {
11+
"id": 52123,
12+
"node_id": "MDEwOlJlcG9zaXRvcnk1MjEyMw==",
13+
"name": "egoh-test-repo-0",
14+
"full_name": "corp/egoh-test-repo-0",
15+
"private": true,
16+
"owner": {
17+
"login": "corp",
18+
"id": 5,
19+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU=",
20+
"avatar_url": "https://github-staging.netflix.net/avatars/u/5?",
21+
"gravatar_id": "",
22+
"url": "https://github-staging.netflix.net/api/v3/users/corp",
23+
"html_url": "https://github-staging.netflix.net/corp",
24+
"followers_url": "https://github-staging.netflix.net/api/v3/users/corp/followers",
25+
"following_url": "https://github-staging.netflix.net/api/v3/users/corp/following{/other_user}",
26+
"gists_url": "https://github-staging.netflix.net/api/v3/users/corp/gists{/gist_id}",
27+
"starred_url": "https://github-staging.netflix.net/api/v3/users/corp/starred{/owner}{/repo}",
28+
"subscriptions_url": "https://github-staging.netflix.net/api/v3/users/corp/subscriptions",
29+
"organizations_url": "https://github-staging.netflix.net/api/v3/users/corp/orgs",
30+
"repos_url": "https://github-staging.netflix.net/api/v3/users/corp/repos",
31+
"events_url": "https://github-staging.netflix.net/api/v3/users/corp/events{/privacy}",
32+
"received_events_url": "https://github-staging.netflix.net/api/v3/users/corp/received_events",
33+
"type": "Organization",
34+
"site_admin": false
35+
},
36+
"html_url": "https://github-staging.netflix.net/corp/egoh-test-repo-0",
37+
"description": null,
38+
"fork": false,
39+
"url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0",
40+
"forks_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/forks",
41+
"keys_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/keys{/key_id}",
42+
"collaborators_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/collaborators{/collaborator}",
43+
"teams_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/teams",
44+
"hooks_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/hooks",
45+
"issue_events_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/issues/events{/number}",
46+
"events_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/events",
47+
"assignees_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/assignees{/user}",
48+
"branches_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/branches{/branch}",
49+
"tags_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/tags",
50+
"blobs_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/git/blobs{/sha}",
51+
"git_tags_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/git/tags{/sha}",
52+
"git_refs_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/git/refs{/sha}",
53+
"trees_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/git/trees{/sha}",
54+
"statuses_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/statuses/{sha}",
55+
"languages_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/languages",
56+
"stargazers_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/stargazers",
57+
"contributors_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/contributors",
58+
"subscribers_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/subscribers",
59+
"subscription_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/subscription",
60+
"commits_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/commits{/sha}",
61+
"git_commits_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/git/commits{/sha}",
62+
"comments_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/comments{/number}",
63+
"issue_comment_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/issues/comments{/number}",
64+
"contents_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/contents/{+path}",
65+
"compare_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/compare/{base}...{head}",
66+
"merges_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/merges",
67+
"archive_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/{archive_format}{/ref}",
68+
"downloads_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/downloads",
69+
"issues_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/issues{/number}",
70+
"pulls_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/pulls{/number}",
71+
"milestones_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/milestones{/number}",
72+
"notifications_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/notifications{?since,all,participating}",
73+
"labels_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/labels{/name}",
74+
"releases_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/releases{/id}",
75+
"deployments_url": "https://github-staging.netflix.net/api/v3/repos/corp/egoh-test-repo-0/deployments",
76+
"created_at": "2024-04-19T21:42:10Z",
77+
"updated_at": "2024-04-19T21:52:25Z",
78+
"pushed_at": "2024-04-19T21:42:12Z",
79+
"git_url": "git://github-staging.netflix.net/corp/egoh-test-repo-0.git",
80+
"ssh_url": "git@github-staging.netflix.net:corp/egoh-test-repo-0.git",
81+
"clone_url": "https://github-staging.netflix.net/corp/egoh-test-repo-0.git",
82+
"svn_url": "https://github-staging.netflix.net/corp/egoh-test-repo-0",
83+
"homepage": null,
84+
"size": 0,
85+
"stargazers_count": 0,
86+
"watchers_count": 0,
87+
"language": null,
88+
"has_issues": true,
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": "internal",
107+
"forks": 0,
108+
"open_issues": 0,
109+
"watchers": 0,
110+
"default_branch": "main"
111+
},
112+
"organization": {
113+
"login": "corp",
114+
"id": 5,
115+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU=",
116+
"url": "https://github-staging.netflix.net/api/v3/orgs/corp",
117+
"repos_url": "https://github-staging.netflix.net/api/v3/orgs/corp/repos",
118+
"events_url": "https://github-staging.netflix.net/api/v3/orgs/corp/events",
119+
"hooks_url": "https://github-staging.netflix.net/api/v3/orgs/corp/hooks",
120+
"issues_url": "https://github-staging.netflix.net/api/v3/orgs/corp/issues",
121+
"members_url": "https://github-staging.netflix.net/api/v3/orgs/corp/members{/member}",
122+
"public_members_url": "https://github-staging.netflix.net/api/v3/orgs/corp/public_members{/member}",
123+
"avatar_url": "https://github-staging.netflix.net/avatars/u/5?",
124+
"description": null
125+
},
126+
"enterprise": {
127+
"id": 1,
128+
"slug": "netflix",
129+
"name": "Netflix",
130+
"node_id": "MDEwOkVudGVycHJpc2Ux",
131+
"avatar_url": "https://github-staging.netflix.net/avatars/b/1?",
132+
"description": null,
133+
"website_url": null,
134+
"html_url": "https://github-staging.netflix.net/enterprises/netflix",
135+
"created_at": "2023-10-12T06:56:57Z",
136+
"updated_at": "2023-11-08T18:37:49Z"
137+
},
138+
"sender": {
139+
"login": "egoh",
140+
"id": 30,
141+
"node_id": "MDQ6VXNlcjMw",
142+
"avatar_url": "https://github-staging.netflix.net/avatars/u/30?",
143+
"gravatar_id": "",
144+
"url": "https://github-staging.netflix.net/api/v3/users/egoh",
145+
"html_url": "https://github-staging.netflix.net/egoh",
146+
"followers_url": "https://github-staging.netflix.net/api/v3/users/egoh/followers",
147+
"following_url": "https://github-staging.netflix.net/api/v3/users/egoh/following{/other_user}",
148+
"gists_url": "https://github-staging.netflix.net/api/v3/users/egoh/gists{/gist_id}",
149+
"starred_url": "https://github-staging.netflix.net/api/v3/users/egoh/starred{/owner}{/repo}",
150+
"subscriptions_url": "https://github-staging.netflix.net/api/v3/users/egoh/subscriptions",
151+
"organizations_url": "https://github-staging.netflix.net/api/v3/users/egoh/orgs",
152+
"repos_url": "https://github-staging.netflix.net/api/v3/users/egoh/repos",
153+
"events_url": "https://github-staging.netflix.net/api/v3/users/egoh/events{/privacy}",
154+
"received_events_url": "https://github-staging.netflix.net/api/v3/users/egoh/received_events",
155+
"type": "User",
156+
"site_admin": true
157+
}
158+
}

0 commit comments

Comments
 (0)