Skip to content

Commit a04ab45

Browse files
authored
Merge pull request #1040 from bitwiseman/bugfix/reposity-id-type
Fix the type of the id parameter of Github#getRepositoryById
2 parents d4cc3af + 0647df2 commit a04ab45

File tree

10 files changed

+1202
-0
lines changed

10 files changed

+1202
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,11 +632,28 @@ public GHRepository getRepository(String name) throws IOException {
632632
* @return the repository by id
633633
* @throws IOException
634634
* the io exception
635+
*
636+
* @deprecated Do not use this method. It was added due to misunderstanding of the type of parameter. Use
637+
* {@link #getRepositoryById(long)} instead
635638
*/
639+
@Deprecated
636640
public GHRepository getRepositoryById(String id) throws IOException {
637641
return createRequest().withUrlPath("/repositories/" + id).fetch(GHRepository.class).wrap(this);
638642
}
639643

644+
/**
645+
* Gets the repository object from its ID
646+
*
647+
* @param id
648+
* the id
649+
* @return the repository by id
650+
* @throws IOException
651+
* the io exception
652+
*/
653+
public GHRepository getRepositoryById(long id) throws IOException {
654+
return createRequest().withUrlPath("/repositories/" + id).fetch(GHRepository.class).wrap(this);
655+
}
656+
640657
/**
641658
* Returns a list of popular open source licenses
642659
*

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ public void setUp() throws Exception {
4545
repo = gitHub.getRepository("hub4j-test-org/GHContentIntegrationTest");
4646
}
4747

48+
@Test
49+
public void testGetRepository() throws Exception {
50+
GHRepository testRepo = gitHub.getRepositoryById(repo.getId());
51+
assertThat(testRepo.getName(), equalTo(repo.getName()));
52+
testRepo = gitHub.getRepositoryById(Long.toString(repo.getId()));
53+
assertThat(testRepo.getName(), equalTo(repo.getName()));
54+
}
55+
4856
@Test
4957
public void testGetFileContent() throws Exception {
5058
repo = gitHub.getRepository("hub4j-test-org/GHContentIntegrationTest");

src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetRepository/__files/repos_hub4j-test-org_ghcontentintegrationtest-2.json

Lines changed: 314 additions & 0 deletions
Large diffs are not rendered by default.

src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetRepository/__files/repositories_40763577-3.json

Lines changed: 314 additions & 0 deletions
Large diffs are not rendered by default.

src/test/resources/org/kohsuke/github/GHContentIntegrationTest/wiremock/testGetRepository/__files/repositories_40763577-4.json

Lines changed: 314 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"login": "bitwiseman",
3+
"id": 1958953,
4+
"node_id": "MDQ6VXNlcjE5NTg5NTM=",
5+
"avatar_url": "https://avatars.githubusercontent.com/u/1958953?v=4",
6+
"gravatar_id": "",
7+
"url": "https://api.github.com/users/bitwiseman",
8+
"html_url": "https://github.com/bitwiseman",
9+
"followers_url": "https://api.github.com/users/bitwiseman/followers",
10+
"following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
11+
"gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
12+
"starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
13+
"subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
14+
"organizations_url": "https://api.github.com/users/bitwiseman/orgs",
15+
"repos_url": "https://api.github.com/users/bitwiseman/repos",
16+
"events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
17+
"received_events_url": "https://api.github.com/users/bitwiseman/received_events",
18+
"type": "User",
19+
"site_admin": false,
20+
"name": "Liam Newman",
21+
"company": "Cloudbees, Inc.",
22+
"blog": "",
23+
"location": "Seattle, WA, USA",
24+
"email": "[email protected]",
25+
"hireable": null,
26+
"bio": null,
27+
"twitter_username": "bitwiseman",
28+
"public_repos": 202,
29+
"public_gists": 8,
30+
"followers": 179,
31+
"following": 11,
32+
"created_at": "2012-07-11T20:38:33Z",
33+
"updated_at": "2021-02-25T18:01:06Z",
34+
"private_gists": 19,
35+
"total_private_repos": 18,
36+
"owned_private_repos": 0,
37+
"disk_usage": 33700,
38+
"collaborators": 0,
39+
"two_factor_authentication": true,
40+
"plan": {
41+
"name": "free",
42+
"space": 976562499,
43+
"collaborators": 0,
44+
"private_repos": 10000
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"id": "87a2df39-f7a4-4ab1-b525-18280943063b",
3+
"name": "repos_hub4j-test-org_ghcontentintegrationtest",
4+
"request": {
5+
"url": "/repos/hub4j-test-org/GHContentIntegrationTest",
6+
"method": "GET",
7+
"headers": {
8+
"Accept": {
9+
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
10+
}
11+
}
12+
},
13+
"response": {
14+
"status": 200,
15+
"bodyFileName": "repos_hub4j-test-org_ghcontentintegrationtest-2.json",
16+
"headers": {
17+
"Server": "GitHub.com",
18+
"Date": "Fri, 26 Feb 2021 21:01:20 GMT",
19+
"Content-Type": "application/json; charset=utf-8",
20+
"Cache-Control": "private, max-age=60, s-maxage=60",
21+
"Vary": [
22+
"Accept, Authorization, Cookie, X-GitHub-OTP",
23+
"Accept-Encoding, Accept, X-Requested-With"
24+
],
25+
"ETag": "W/\"81f9a2e101e45e0cf1d1a6dad02a3cd1b7fade390acc969b0be9ecf5f9baf78f\"",
26+
"last-modified": "Thu, 02 Jul 2020 15:49:49 GMT",
27+
"X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, workflow, write:discussion",
28+
"X-Accepted-OAuth-Scopes": "repo",
29+
"X-GitHub-Media-Type": "unknown, github.v3",
30+
"X-RateLimit-Limit": "5000",
31+
"X-RateLimit-Remaining": "4985",
32+
"X-RateLimit-Reset": "1614376173",
33+
"x-ratelimit-used": "15",
34+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
35+
"X-Frame-Options": "deny",
36+
"X-Content-Type-Options": "nosniff",
37+
"X-XSS-Protection": "1; mode=block",
38+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
39+
"Content-Security-Policy": "default-src 'none'",
40+
"X-GitHub-Request-Id": "E09B:19E1:19D680:1BB3AE:603961A0"
41+
}
42+
},
43+
"uuid": "87a2df39-f7a4-4ab1-b525-18280943063b",
44+
"persistent": true,
45+
"insertionIndex": 2
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"id": "e70b6cc9-f74f-4912-8d68-a7f86ac02fc5",
3+
"name": "repositories_40763577",
4+
"request": {
5+
"url": "/repositories/40763577",
6+
"method": "GET",
7+
"headers": {
8+
"Accept": {
9+
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
10+
}
11+
}
12+
},
13+
"response": {
14+
"status": 200,
15+
"bodyFileName": "repositories_40763577-3.json",
16+
"headers": {
17+
"Server": "GitHub.com",
18+
"Date": "Fri, 26 Feb 2021 21:01:21 GMT",
19+
"Content-Type": "application/json; charset=utf-8",
20+
"Cache-Control": "private, max-age=60, s-maxage=60",
21+
"Vary": [
22+
"Accept, Authorization, Cookie, X-GitHub-OTP",
23+
"Accept-Encoding, Accept, X-Requested-With"
24+
],
25+
"ETag": "W/\"81f9a2e101e45e0cf1d1a6dad02a3cd1b7fade390acc969b0be9ecf5f9baf78f\"",
26+
"last-modified": "Thu, 02 Jul 2020 15:49:49 GMT",
27+
"X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, workflow, write:discussion",
28+
"X-Accepted-OAuth-Scopes": "repo",
29+
"X-GitHub-Media-Type": "unknown, github.v3",
30+
"X-RateLimit-Limit": "5000",
31+
"X-RateLimit-Remaining": "4984",
32+
"X-RateLimit-Reset": "1614376173",
33+
"x-ratelimit-used": "16",
34+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
35+
"X-Frame-Options": "deny",
36+
"X-Content-Type-Options": "nosniff",
37+
"X-XSS-Protection": "1; mode=block",
38+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
39+
"Content-Security-Policy": "default-src 'none'",
40+
"X-GitHub-Request-Id": "E09B:19E1:19D697:1BB3C7:603961A0"
41+
}
42+
},
43+
"uuid": "e70b6cc9-f74f-4912-8d68-a7f86ac02fc5",
44+
"persistent": true,
45+
"scenarioName": "scenario-1-repositories-40763577",
46+
"requiredScenarioState": "Started",
47+
"newScenarioState": "scenario-1-repositories-40763577-2",
48+
"insertionIndex": 3
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"id": "7349ea56-3864-40ac-b264-392233b2b220",
3+
"name": "repositories_40763577",
4+
"request": {
5+
"url": "/repositories/40763577",
6+
"method": "GET",
7+
"headers": {
8+
"Accept": {
9+
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
10+
}
11+
}
12+
},
13+
"response": {
14+
"status": 200,
15+
"bodyFileName": "repositories_40763577-4.json",
16+
"headers": {
17+
"Server": "GitHub.com",
18+
"Date": "Fri, 26 Feb 2021 21:01:21 GMT",
19+
"Content-Type": "application/json; charset=utf-8",
20+
"Cache-Control": "private, max-age=60, s-maxage=60",
21+
"Vary": [
22+
"Accept, Authorization, Cookie, X-GitHub-OTP",
23+
"Accept-Encoding, Accept, X-Requested-With"
24+
],
25+
"ETag": "W/\"81f9a2e101e45e0cf1d1a6dad02a3cd1b7fade390acc969b0be9ecf5f9baf78f\"",
26+
"last-modified": "Thu, 02 Jul 2020 15:49:49 GMT",
27+
"X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, workflow, write:discussion",
28+
"X-Accepted-OAuth-Scopes": "repo",
29+
"X-GitHub-Media-Type": "unknown, github.v3",
30+
"X-RateLimit-Limit": "5000",
31+
"X-RateLimit-Remaining": "4983",
32+
"X-RateLimit-Reset": "1614376173",
33+
"x-ratelimit-used": "17",
34+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
35+
"X-Frame-Options": "deny",
36+
"X-Content-Type-Options": "nosniff",
37+
"X-XSS-Protection": "1; mode=block",
38+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
39+
"Content-Security-Policy": "default-src 'none'",
40+
"X-GitHub-Request-Id": "E09B:19E1:19D6B4:1BB3E2:603961A1"
41+
}
42+
},
43+
"uuid": "7349ea56-3864-40ac-b264-392233b2b220",
44+
"persistent": true,
45+
"scenarioName": "scenario-1-repositories-40763577",
46+
"requiredScenarioState": "scenario-1-repositories-40763577-2",
47+
"insertionIndex": 4
48+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"id": "33bf871a-36a1-40d2-8a85-93241987a09a",
3+
"name": "user",
4+
"request": {
5+
"url": "/user",
6+
"method": "GET",
7+
"headers": {
8+
"Accept": {
9+
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
10+
}
11+
}
12+
},
13+
"response": {
14+
"status": 200,
15+
"bodyFileName": "user-1.json",
16+
"headers": {
17+
"Server": "GitHub.com",
18+
"Date": "Fri, 26 Feb 2021 21:01:19 GMT",
19+
"Content-Type": "application/json; charset=utf-8",
20+
"Cache-Control": "private, max-age=60, s-maxage=60",
21+
"Vary": [
22+
"Accept, Authorization, Cookie, X-GitHub-OTP",
23+
"Accept-Encoding, Accept, X-Requested-With"
24+
],
25+
"ETag": "W/\"55ec271927b9b427b6dc1946829a82631f592d13765bb00fa4015784b3ef58bd\"",
26+
"last-modified": "Thu, 25 Feb 2021 18:01:06 GMT",
27+
"X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, workflow, write:discussion",
28+
"X-Accepted-OAuth-Scopes": "",
29+
"X-GitHub-Media-Type": "unknown, github.v3",
30+
"X-RateLimit-Limit": "5000",
31+
"X-RateLimit-Remaining": "4989",
32+
"X-RateLimit-Reset": "1614376173",
33+
"x-ratelimit-used": "11",
34+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
35+
"X-Frame-Options": "deny",
36+
"X-Content-Type-Options": "nosniff",
37+
"X-XSS-Protection": "1; mode=block",
38+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
39+
"Content-Security-Policy": "default-src 'none'",
40+
"X-GitHub-Request-Id": "E09B:19E1:19D5FB:1BB32E:6039619F"
41+
}
42+
},
43+
"uuid": "33bf871a-36a1-40d2-8a85-93241987a09a",
44+
"persistent": true,
45+
"insertionIndex": 1
46+
}

0 commit comments

Comments
 (0)