Skip to content

Commit

Permalink
Merge pull request #1040 from bitwiseman/bugfix/reposity-id-type
Browse files Browse the repository at this point in the history
Fix the type of the id parameter of Github#getRepositoryById
  • Loading branch information
bitwiseman authored Feb 26, 2021
2 parents d4cc3af + 0647df2 commit a04ab45
Show file tree
Hide file tree
Showing 10 changed files with 1,202 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/org/kohsuke/github/GitHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -632,11 +632,28 @@ public GHRepository getRepository(String name) throws IOException {
* @return the repository by id
* @throws IOException
* the io exception
*
* @deprecated Do not use this method. It was added due to misunderstanding of the type of parameter. Use
* {@link #getRepositoryById(long)} instead
*/
@Deprecated
public GHRepository getRepositoryById(String id) throws IOException {
return createRequest().withUrlPath("/repositories/" + id).fetch(GHRepository.class).wrap(this);
}

/**
* Gets the repository object from its ID
*
* @param id
* the id
* @return the repository by id
* @throws IOException
* the io exception
*/
public GHRepository getRepositoryById(long id) throws IOException {
return createRequest().withUrlPath("/repositories/" + id).fetch(GHRepository.class).wrap(this);
}

/**
* Returns a list of popular open source licenses
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ public void setUp() throws Exception {
repo = gitHub.getRepository("hub4j-test-org/GHContentIntegrationTest");
}

@Test
public void testGetRepository() throws Exception {
GHRepository testRepo = gitHub.getRepositoryById(repo.getId());
assertThat(testRepo.getName(), equalTo(repo.getName()));
testRepo = gitHub.getRepositoryById(Long.toString(repo.getId()));
assertThat(testRepo.getName(), equalTo(repo.getName()));
}

@Test
public void testGetFileContent() throws Exception {
repo = gitHub.getRepository("hub4j-test-org/GHContentIntegrationTest");
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

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

0 comments on commit a04ab45

Please sign in to comment.