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

Commit dc615e4

Browse filesBrowse files
authored
Merge pull request hub4j#985 from lower-case/bugfix-883
Fixes null commit date
2 parents b30d648 + cf9caa6 commit dc615e4
Copy full SHA for dc615e4

File tree

Expand file treeCollapse file tree

10 files changed

+850
-4
lines changed
Filter options
Expand file treeCollapse file tree

10 files changed

+850
-4
lines changed

‎src/main/java/org/kohsuke/github/GHCommit.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHCommit.java
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public GitUser getAuthor() {
6666
* @return the authored date
6767
*/
6868
public Date getAuthoredDate() {
69-
return GitHubClient.parseDate(author.date);
69+
return author.getDate();
7070
}
7171

7272
/**
@@ -85,7 +85,7 @@ public GitUser getCommitter() {
8585
* @return the commit date
8686
*/
8787
public Date getCommitDate() {
88-
return GitHubClient.parseDate(committer.date);
88+
return committer.getDate();
8989
}
9090

9191
/**
@@ -122,7 +122,6 @@ public GHVerification getVerification() {
122122
* @deprecated Use {@link GitUser} instead.
123123
*/
124124
public static class GHAuthor extends GitUser {
125-
private String date;
126125
}
127126

128127
/**

‎src/main/java/org/kohsuke/github/GitUser.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GitUser.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public String getUsername() {
5050
/**
5151
* Gets date.
5252
*
53-
* @return This field doesn't appear to be consistently available in all the situations where this class is used.
53+
* @return Commit Date.
5454
*/
5555
public Date getDate() {
5656
return GitHubClient.parseDate(date);

‎src/test/java/org/kohsuke/github/AppTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/AppTest.java
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,10 @@ public void testCommitShortInfo() throws Exception {
672672
assertEquals(commit.getCommitShortInfo().getMessage(), "doc");
673673
assertFalse(commit.getCommitShortInfo().getVerification().isVerified());
674674
assertEquals(commit.getCommitShortInfo().getVerification().getReason(), GHVerification.Reason.UNSIGNED);
675+
assertThat(commit.getCommitShortInfo().getAuthor().getDate().toInstant().getEpochSecond(),
676+
equalTo(1271650361L));
677+
assertThat(commit.getCommitShortInfo().getCommitter().getDate().toInstant().getEpochSecond(),
678+
equalTo(1271650361L));
675679
}
676680

677681
@Ignore("Needs mocking check")

‎src/test/java/org/kohsuke/github/CommitTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/CommitTest.java
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import java.util.Arrays;
88
import java.util.List;
99

10+
import static org.hamcrest.Matchers.equalTo;
11+
1012
/**
1113
* @author Kohsuke Kawaguchi
1214
*/
@@ -120,4 +122,17 @@ public void commitSignatureVerification() throws Exception {
120122
commit.getCommitShortInfo().getVerification().getPayload());
121123
}
122124
}
125+
126+
@Test // issue 883
127+
public void commitDateNotNull() throws Exception {
128+
GHRepository repo = gitHub.getRepository("hub4j/github-api");
129+
GHCommit commit = repo.getCommit("865a49d2e86c24c5777985f0f103e975c4b765b9");
130+
131+
assertThat(commit.getCommitShortInfo().getAuthoredDate().toInstant().getEpochSecond(), equalTo(1609207093L));
132+
assertThat(commit.getCommitShortInfo().getAuthoredDate(),
133+
equalTo(commit.getCommitShortInfo().getAuthor().getDate()));
134+
assertThat(commit.getCommitShortInfo().getCommitDate().toInstant().getEpochSecond(), equalTo(1609207652L));
135+
assertThat(commit.getCommitShortInfo().getCommitDate(),
136+
equalTo(commit.getCommitShortInfo().getCommitter().getDate()));
137+
}
123138
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
{
2+
"id": 617210,
3+
"node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=",
4+
"name": "github-api",
5+
"full_name": "hub4j/github-api",
6+
"private": false,
7+
"owner": {
8+
"login": "hub4j",
9+
"id": 54909825,
10+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
11+
"avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
12+
"gravatar_id": "",
13+
"url": "https://api.github.com/users/hub4j",
14+
"html_url": "https://github.com/hub4j",
15+
"followers_url": "https://api.github.com/users/hub4j/followers",
16+
"following_url": "https://api.github.com/users/hub4j/following{/other_user}",
17+
"gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}",
18+
"starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}",
19+
"subscriptions_url": "https://api.github.com/users/hub4j/subscriptions",
20+
"organizations_url": "https://api.github.com/users/hub4j/orgs",
21+
"repos_url": "https://api.github.com/users/hub4j/repos",
22+
"events_url": "https://api.github.com/users/hub4j/events{/privacy}",
23+
"received_events_url": "https://api.github.com/users/hub4j/received_events",
24+
"type": "Organization",
25+
"site_admin": false
26+
},
27+
"html_url": "https://github.com/hub4j/github-api",
28+
"description": "Java API for GitHub",
29+
"fork": false,
30+
"url": "https://api.github.com/repos/hub4j/github-api",
31+
"forks_url": "https://api.github.com/repos/hub4j/github-api/forks",
32+
"keys_url": "https://api.github.com/repos/hub4j/github-api/keys{/key_id}",
33+
"collaborators_url": "https://api.github.com/repos/hub4j/github-api/collaborators{/collaborator}",
34+
"teams_url": "https://api.github.com/repos/hub4j/github-api/teams",
35+
"hooks_url": "https://api.github.com/repos/hub4j/github-api/hooks",
36+
"issue_events_url": "https://api.github.com/repos/hub4j/github-api/issues/events{/number}",
37+
"events_url": "https://api.github.com/repos/hub4j/github-api/events",
38+
"assignees_url": "https://api.github.com/repos/hub4j/github-api/assignees{/user}",
39+
"branches_url": "https://api.github.com/repos/hub4j/github-api/branches{/branch}",
40+
"tags_url": "https://api.github.com/repos/hub4j/github-api/tags",
41+
"blobs_url": "https://api.github.com/repos/hub4j/github-api/git/blobs{/sha}",
42+
"git_tags_url": "https://api.github.com/repos/hub4j/github-api/git/tags{/sha}",
43+
"git_refs_url": "https://api.github.com/repos/hub4j/github-api/git/refs{/sha}",
44+
"trees_url": "https://api.github.com/repos/hub4j/github-api/git/trees{/sha}",
45+
"statuses_url": "https://api.github.com/repos/hub4j/github-api/statuses/{sha}",
46+
"languages_url": "https://api.github.com/repos/hub4j/github-api/languages",
47+
"stargazers_url": "https://api.github.com/repos/hub4j/github-api/stargazers",
48+
"contributors_url": "https://api.github.com/repos/hub4j/github-api/contributors",
49+
"subscribers_url": "https://api.github.com/repos/hub4j/github-api/subscribers",
50+
"subscription_url": "https://api.github.com/repos/hub4j/github-api/subscription",
51+
"commits_url": "https://api.github.com/repos/hub4j/github-api/commits{/sha}",
52+
"git_commits_url": "https://api.github.com/repos/hub4j/github-api/git/commits{/sha}",
53+
"comments_url": "https://api.github.com/repos/hub4j/github-api/comments{/number}",
54+
"issue_comment_url": "https://api.github.com/repos/hub4j/github-api/issues/comments{/number}",
55+
"contents_url": "https://api.github.com/repos/hub4j/github-api/contents/{+path}",
56+
"compare_url": "https://api.github.com/repos/hub4j/github-api/compare/{base}...{head}",
57+
"merges_url": "https://api.github.com/repos/hub4j/github-api/merges",
58+
"archive_url": "https://api.github.com/repos/hub4j/github-api/{archive_format}{/ref}",
59+
"downloads_url": "https://api.github.com/repos/hub4j/github-api/downloads",
60+
"issues_url": "https://api.github.com/repos/hub4j/github-api/issues{/number}",
61+
"pulls_url": "https://api.github.com/repos/hub4j/github-api/pulls{/number}",
62+
"milestones_url": "https://api.github.com/repos/hub4j/github-api/milestones{/number}",
63+
"notifications_url": "https://api.github.com/repos/hub4j/github-api/notifications{?since,all,participating}",
64+
"labels_url": "https://api.github.com/repos/hub4j/github-api/labels{/name}",
65+
"releases_url": "https://api.github.com/repos/hub4j/github-api/releases{/id}",
66+
"deployments_url": "https://api.github.com/repos/hub4j/github-api/deployments",
67+
"created_at": "2010-04-19T04:13:03Z",
68+
"updated_at": "2020-12-29T03:54:49Z",
69+
"pushed_at": "2020-12-29T03:54:45Z",
70+
"git_url": "git://github.com/hub4j/github-api.git",
71+
"ssh_url": "git@github.com:hub4j/github-api.git",
72+
"clone_url": "https://github.com/hub4j/github-api.git",
73+
"svn_url": "https://github.com/hub4j/github-api",
74+
"homepage": "https://github-api.kohsuke.org/",
75+
"size": 25580,
76+
"stargazers_count": 725,
77+
"watchers_count": 725,
78+
"language": "Java",
79+
"has_issues": true,
80+
"has_projects": true,
81+
"has_downloads": true,
82+
"has_wiki": true,
83+
"has_pages": true,
84+
"forks_count": 514,
85+
"mirror_url": null,
86+
"archived": false,
87+
"disabled": false,
88+
"open_issues_count": 74,
89+
"license": {
90+
"key": "mit",
91+
"name": "MIT License",
92+
"spdx_id": "MIT",
93+
"url": "https://api.github.com/licenses/mit",
94+
"node_id": "MDc6TGljZW5zZTEz"
95+
},
96+
"forks": 514,
97+
"open_issues": 74,
98+
"watchers": 725,
99+
"default_branch": "master",
100+
"permissions": {
101+
"admin": true,
102+
"push": true,
103+
"pull": true
104+
},
105+
"temp_clone_token": "",
106+
"allow_squash_merge": true,
107+
"allow_merge_commit": true,
108+
"allow_rebase_merge": true,
109+
"delete_branch_on_merge": false,
110+
"organization": {
111+
"login": "hub4j",
112+
"id": 54909825,
113+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
114+
"avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
115+
"gravatar_id": "",
116+
"url": "https://api.github.com/users/hub4j",
117+
"html_url": "https://github.com/hub4j",
118+
"followers_url": "https://api.github.com/users/hub4j/followers",
119+
"following_url": "https://api.github.com/users/hub4j/following{/other_user}",
120+
"gists_url": "https://api.github.com/users/hub4j/gists{/gist_id}",
121+
"starred_url": "https://api.github.com/users/hub4j/starred{/owner}{/repo}",
122+
"subscriptions_url": "https://api.github.com/users/hub4j/subscriptions",
123+
"organizations_url": "https://api.github.com/users/hub4j/orgs",
124+
"repos_url": "https://api.github.com/users/hub4j/repos",
125+
"events_url": "https://api.github.com/users/hub4j/events{/privacy}",
126+
"received_events_url": "https://api.github.com/users/hub4j/received_events",
127+
"type": "Organization",
128+
"site_admin": false
129+
},
130+
"network_count": 514,
131+
"subscribers_count": 50
132+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.