Merge pull request #985 from lower-case/bugfix-883

Fixes null commit date
This commit is contained in:
Liam Newman
2020-12-28 22:06:47 -08:00
committed by GitHub
10 changed files with 850 additions and 4 deletions

View File

@@ -66,7 +66,7 @@ public class GHCommit {
* @return the authored date
*/
public Date getAuthoredDate() {
return GitHubClient.parseDate(author.date);
return author.getDate();
}
/**
@@ -85,7 +85,7 @@ public class GHCommit {
* @return the commit date
*/
public Date getCommitDate() {
return GitHubClient.parseDate(committer.date);
return committer.getDate();
}
/**
@@ -122,7 +122,6 @@ public class GHCommit {
* @deprecated Use {@link GitUser} instead.
*/
public static class GHAuthor extends GitUser {
private String date;
}
/**

View File

@@ -50,7 +50,7 @@ public class GitUser {
/**
* Gets date.
*
* @return This field doesn't appear to be consistently available in all the situations where this class is used.
* @return Commit Date.
*/
public Date getDate() {
return GitHubClient.parseDate(date);

View File

@@ -672,6 +672,10 @@ public class AppTest extends AbstractGitHubWireMockTest {
assertEquals(commit.getCommitShortInfo().getMessage(), "doc");
assertFalse(commit.getCommitShortInfo().getVerification().isVerified());
assertEquals(commit.getCommitShortInfo().getVerification().getReason(), GHVerification.Reason.UNSIGNED);
assertThat(commit.getCommitShortInfo().getAuthor().getDate().toInstant().getEpochSecond(),
equalTo(1271650361L));
assertThat(commit.getCommitShortInfo().getCommitter().getDate().toInstant().getEpochSecond(),
equalTo(1271650361L));
}
@Ignore("Needs mocking check")

View File

@@ -7,6 +7,8 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import static org.hamcrest.Matchers.equalTo;
/**
* @author Kohsuke Kawaguchi
*/
@@ -120,4 +122,17 @@ public class CommitTest extends AbstractGitHubWireMockTest {
commit.getCommitShortInfo().getVerification().getPayload());
}
}
@Test // issue 883
public void commitDateNotNull() throws Exception {
GHRepository repo = gitHub.getRepository("hub4j/github-api");
GHCommit commit = repo.getCommit("865a49d2e86c24c5777985f0f103e975c4b765b9");
assertThat(commit.getCommitShortInfo().getAuthoredDate().toInstant().getEpochSecond(), equalTo(1609207093L));
assertThat(commit.getCommitShortInfo().getAuthoredDate(),
equalTo(commit.getCommitShortInfo().getAuthor().getDate()));
assertThat(commit.getCommitShortInfo().getCommitDate().toInstant().getEpochSecond(), equalTo(1609207652L));
assertThat(commit.getCommitShortInfo().getCommitDate(),
equalTo(commit.getCommitShortInfo().getCommitter().getDate()));
}
}

View File

@@ -0,0 +1,132 @@
{
"id": 617210,
"node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=",
"name": "github-api",
"full_name": "hub4j/github-api",
"private": false,
"owner": {
"login": "hub4j",
"id": 54909825,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
"avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/hub4j",
"html_url": "https://github.com/hub4j",
"followers_url": "https://api.github.com/users/hub4j/followers",
"following_url": "https://api.github.com/users/hub4j/following{/other_user}",
"gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}",
"starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/hub4j/subscriptions",
"organizations_url": "https://api.github.com/users/hub4j/orgs",
"repos_url": "https://api.github.com/users/hub4j/repos",
"events_url": "https://api.github.com/users/hub4j/events{/privacy}",
"received_events_url": "https://api.github.com/users/hub4j/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/hub4j/github-api",
"description": "Java API for GitHub",
"fork": false,
"url": "https://api.github.com/repos/hub4j/github-api",
"forks_url": "https://api.github.com/repos/hub4j/github-api/forks",
"keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/hub4j/github-api/teams",
"hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks",
"issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}",
"events_url": "https://api.github.com/repos/hub4j/github-api/events",
"assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}",
"branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}",
"tags_url": "https://api.github.com/repos/hub4j/github-api/tags",
"blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}",
"languages_url": "https://api.github.com/repos/hub4j/github-api/languages",
"stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers",
"contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors",
"subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers",
"subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription",
"commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}",
"compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/hub4j/github-api/merges",
"archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads",
"issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}",
"pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}",
"milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}",
"notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}",
"releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}",
"deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments",
"created_at": "2010-04-19T04:13:03Z",
"updated_at": "2020-12-29T03:54:49Z",
"pushed_at": "2020-12-29T03:54:45Z",
"git_url": "git://github.com/hub4j/github-api.git",
"ssh_url": "git@github.com:hub4j/github-api.git",
"clone_url": "https://github.com/hub4j/github-api.git",
"svn_url": "https://github.com/hub4j/github-api",
"homepage": "https://github-api.kohsuke.org/",
"size": 25580,
"stargazers_count": 725,
"watchers_count": 725,
"language": "Java",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": true,
"forks_count": 514,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 74,
"license": {
"key": "mit",
"name": "MIT License",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"node_id": "MDc6TGljZW5zZTEz"
},
"forks": 514,
"open_issues": 74,
"watchers": 725,
"default_branch": "master",
"permissions": {
"admin": true,
"push": true,
"pull": true
},
"temp_clone_token": "",
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"delete_branch_on_merge": false,
"organization": {
"login": "hub4j",
"id": 54909825,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
"avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/hub4j",
"html_url": "https://github.com/hub4j",
"followers_url": "https://api.github.com/users/hub4j/followers",
"following_url": "https://api.github.com/users/hub4j/following{/other_user}",
"gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}",
"starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/hub4j/subscriptions",
"organizations_url": "https://api.github.com/users/hub4j/orgs",
"repos_url": "https://api.github.com/users/hub4j/repos",
"events_url": "https://api.github.com/users/hub4j/events{/privacy}",
"received_events_url": "https://api.github.com/users/hub4j/received_events",
"type": "Organization",
"site_admin": false
},
"network_count": 514,
"subscribers_count": 50
}

View File

@@ -0,0 +1,46 @@
{
"login": "bitwiseman",
"id": 1958953,
"node_id": "MDQ6VXNlcjE5NTg5NTM=",
"avatar_url": "https://avatars3.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": "bitwiseman@gmail.com",
"hireable": null,
"bio": null,
"twitter_username": "bitwiseman",
"public_repos": 199,
"public_gists": 7,
"followers": 174,
"following": 11,
"created_at": "2012-07-11T20:38:33Z",
"updated_at": "2020-12-23T22:23:08Z",
"private_gists": 19,
"total_private_repos": 17,
"owned_private_repos": 0,
"disk_usage": 33700,
"collaborators": 0,
"two_factor_authentication": true,
"plan": {
"name": "free",
"space": 976562499,
"collaborators": 0,
"private_repos": 10000
}
}

View File

@@ -0,0 +1,48 @@
{
"id": "87ba83b3-361d-4fbe-a4c0-1a92c73911e0",
"name": "repos_hub4j_github-api",
"request": {
"url": "/repos/hub4j/github-api",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
}
}
},
"response": {
"status": 200,
"bodyFileName": "repos_hub4j_github-api-2.json",
"headers": {
"Date": "Tue, 29 Dec 2020 04:17:02 GMT",
"Content-Type": "application/json; charset=utf-8",
"Server": "GitHub.com",
"Status": "200 OK",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding, Accept, X-Requested-With",
"Accept-Encoding"
],
"ETag": "W/\"6fc2ccdf4af0f89cf88fddff7099dd479f7a15b5551d5ced73e3e4e0384b24c6\"",
"Last-Modified": "Tue, 29 Dec 2020 03:54: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": "4966",
"X-RateLimit-Reset": "1609216145",
"X-RateLimit-Used": "34",
"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": "DEAA:85CA:20A7397:284A8E0:5FEAADBD"
}
},
"uuid": "87ba83b3-361d-4fbe-a4c0-1a92c73911e0",
"persistent": true,
"insertionIndex": 2
}

View File

@@ -0,0 +1,48 @@
{
"id": "5c1536ce-299a-40b4-ad5a-a21777294471",
"name": "repos_hub4j_github-api_commits_865a49d2e86c24c5777985f0f103e975c4b765b9",
"request": {
"url": "/repos/hub4j/github-api/commits/865a49d2e86c24c5777985f0f103e975c4b765b9",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
}
}
},
"response": {
"status": 200,
"bodyFileName": "repos_hub4j_github-api_commits_865a49d2e86c24c5777985f0f103e975c4b765b9-3.json",
"headers": {
"Date": "Tue, 29 Dec 2020 04:17:02 GMT",
"Content-Type": "application/json; charset=utf-8",
"Server": "GitHub.com",
"Status": "200 OK",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding, Accept, X-Requested-With",
"Accept-Encoding"
],
"ETag": "W/\"329c39539737a3ce25b0c6fece22145a13b9b0d69604f0fe77d71f562a9130ab\"",
"Last-Modified": "Tue, 29 Dec 2020 02:07:32 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": "4965",
"X-RateLimit-Reset": "1609216145",
"X-RateLimit-Used": "35",
"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": "DEAA:85CA:20A73A6:284A912:5FEAADBE"
}
},
"uuid": "5c1536ce-299a-40b4-ad5a-a21777294471",
"persistent": true,
"insertionIndex": 3
}

View File

@@ -0,0 +1,48 @@
{
"id": "2d8f404b-6b92-43f5-9edd-a0ecc00dc866",
"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": {
"Date": "Tue, 29 Dec 2020 04:17:01 GMT",
"Content-Type": "application/json; charset=utf-8",
"Server": "GitHub.com",
"Status": "200 OK",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding, Accept, X-Requested-With",
"Accept-Encoding"
],
"ETag": "W/\"bb2babcbd8a6f75f8e5bbf778f169fdb662bf030c0f4a81ed94fde38b7c93347\"",
"Last-Modified": "Wed, 23 Dec 2020 22:23:08 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": "4968",
"X-RateLimit-Reset": "1609216145",
"X-RateLimit-Used": "32",
"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": "DEAA:85CA:20A736D:284A8D5:5FEAADBD"
}
},
"uuid": "2d8f404b-6b92-43f5-9edd-a0ecc00dc866",
"persistent": true,
"insertionIndex": 1
}