Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fixes null commit date #985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fixes null commit date
  • Loading branch information
lower-case committed Nov 28, 2020
commit 938603ff60cafc9952572f58bccd7d4875e5dd6e
5 changes: 2 additions & 3 deletions 5 src/main/java/org/kohsuke/github/GHCommit.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public GitUser getAuthor() {
* @return the authored date
*/
public Date getAuthoredDate() {
return GitHubClient.parseDate(author.date);
return author.getDate();
}

/**
Expand All @@ -84,7 +84,7 @@ public GitUser getCommitter() {
* @return the commit date
*/
public Date getCommitDate() {
return GitHubClient.parseDate(committer.date);
return committer.getDate();
}

/**
Expand Down Expand Up @@ -121,7 +121,6 @@ public GHVerification getVerification() {
* @deprecated Use {@link GitUser} instead.
*/
public static class GHAuthor extends GitUser {
private String date;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion 2 src/main/java/org/kohsuke/github/GitUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public String getUsername() {
/**
* 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);
Expand Down
9 changes: 9 additions & 0 deletions 9 src/test/java/org/kohsuke/github/CommitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,13 @@ public void commitSignatureVerification() throws Exception {
commit.getCommitShortInfo().getVerification().getPayload());
}
}

@Test // issue 883
public void commitDateNotNull() throws Exception {
GHRepository repo = gitHub.getRepository("hub4j/github-api");
GHCommit commit = repo.getCommit("ed4f9c8176866977677c99ac9668a8ce10231bc8");

assertNotNull(commit.getCommitShortInfo().getAuthoredDate());
Copy link
Member

@bitwiseman bitwiseman Nov 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check for more than just not null. There is a known expected value that isn't going to change over time. Check for the correct value and that the two methods return the same value.

assertNotNull(commit.getCommitShortInfo().getAuthor().getDate());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{
"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-11-28T05:59:13Z",
"pushed_at": "2020-11-27T17:23:57Z",
"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": 25463,
"stargazers_count": 714,
"watchers_count": 714,
"language": "Java",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": true,
"forks_count": 511,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 79,
"license": {
"key": "mit",
"name": "MIT License",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"node_id": "MDc6TGljZW5zZTEz"
},
"forks": 511,
"open_issues": 79,
"watchers": 714,
"default_branch": "master",
"permissions": {
"admin": false,
"push": false,
"pull": true
},
"temp_clone_token": "",
"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": 511,
"subscribers_count": 47
}
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.