Merge pull request #1026 from jordiolivares/feature/timestamp-support

Add timestamp field support for the commits sent by GHEventPayload.Push
This commit is contained in:
Liam Newman
2021-01-28 18:00:48 -08:00
committed by GitHub
2 changed files with 14 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.io.Reader;
import java.util.Date;
import java.util.List;
/**
@@ -1067,7 +1068,7 @@ public class GHEventPayload extends GitHubInteractiveObject {
public static class PushCommit {
private GitUser author;
private GitUser committer;
private String url, sha, message;
private String url, sha, message, timestamp;
private boolean distinct;
private List<String> added, removed, modified;
@@ -1156,6 +1157,15 @@ public class GHEventPayload extends GitHubInteractiveObject {
public List<String> getModified() {
return modified;
}
/**
* Obtains the timestamp of the commit
*
* @return the timestamp
*/
public Date getTimestamp() {
return GitHubClient.parseDate(timestamp);
}
}
}

View File

@@ -361,6 +361,9 @@ public class GHEventPayloadTest extends AbstractGitHubWireMockTest {
assertThat(event.getCommits().get(0).getRemoved().size(), is(0));
assertThat(event.getCommits().get(0).getModified().size(), is(1));
assertThat(event.getCommits().get(0).getModified().get(0), is("README.md"));
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
assertThat(formatter.format(event.getCommits().get(0).getTimestamp()), is("2015-05-05T23:40:15Z"));
assertThat(event.getRepository().getName(), is("public-repo"));
assertThat(event.getRepository().getOwnerName(), is("baxterthehacker"));
assertThat(event.getRepository().getUrl().toExternalForm(),