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 b3460c1

Browse filesBrowse files
committed
Add timestamp field support for the commits sent by GHEventPayload.Push
1 parent 5166c92 commit b3460c1
Copy full SHA for b3460c1

File tree

Expand file treeCollapse file tree

2 files changed

+13
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHEventPayload.java
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.io.IOException;
77
import java.io.Reader;
8+
import java.util.Date;
89
import java.util.List;
910

1011
/**
@@ -1067,7 +1068,7 @@ public void setEmail(String email) {
10671068
public static class PushCommit {
10681069
private GitUser author;
10691070
private GitUser committer;
1070-
private String url, sha, message;
1071+
private String url, sha, message, timestamp;
10711072
private boolean distinct;
10721073
private List<String> added, removed, modified;
10731074

@@ -1156,6 +1157,14 @@ public List<String> getRemoved() {
11561157
public List<String> getModified() {
11571158
return modified;
11581159
}
1160+
1161+
/**
1162+
* Obtains the timestamp of the commit
1163+
* @return the timestamp
1164+
*/
1165+
public Date getTimestamp() {
1166+
return GitHubClient.parseDate(timestamp);
1167+
}
11591168
}
11601169
}
11611170

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

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/GHEventPayloadTest.java
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ public void push() throws Exception {
361361
assertThat(event.getCommits().get(0).getRemoved().size(), is(0));
362362
assertThat(event.getCommits().get(0).getModified().size(), is(1));
363363
assertThat(event.getCommits().get(0).getModified().get(0), is("README.md"));
364+
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
365+
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
366+
assertThat(formatter.format(event.getCommits().get(0).getTimestamp()), is("2015-05-05T23:40:15Z"));
364367
assertThat(event.getRepository().getName(), is("public-repo"));
365368
assertThat(event.getRepository().getOwnerName(), is("baxterthehacker"));
366369
assertThat(event.getRepository().getUrl().toExternalForm(),

0 commit comments

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