From 50b47fb73b538d4e7b80c9414c3410e727f0ace3 Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Mon, 24 Oct 2016 21:12:56 +0100 Subject: [PATCH] Expose the commit dates --- .../java/org/kohsuke/github/GHCommit.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/kohsuke/github/GHCommit.java b/src/main/java/org/kohsuke/github/GHCommit.java index 6e606ef603..5872233567 100644 --- a/src/main/java/org/kohsuke/github/GHCommit.java +++ b/src/main/java/org/kohsuke/github/GHCommit.java @@ -2,12 +2,12 @@ import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - import java.io.IOException; import java.net.URL; import java.util.AbstractList; import java.util.ArrayList; import java.util.Collections; +import java.util.Date; import java.util.List; /** @@ -42,11 +42,19 @@ public GitUser getAuthor() { return author; } + public Date getAuthoredDate() { + return GitHub.parseDate(author.date); + } + @WithBridgeMethods(value = GHAuthor.class, castRequired = true) public GitUser getCommitter() { return committer; } + public Date getCommitDate() { + return GitHub.parseDate(author.date); + } + /** * Commit message. */ @@ -63,6 +71,7 @@ public int getCommentCount() { * @deprecated Use {@link GitUser} instead. */ public static class GHAuthor extends GitUser { + private String date; } public static class Stats { @@ -272,10 +281,29 @@ public GHUser getAuthor() throws IOException { return resolveUser(author); } + /** + * Gets the date the change was authored on. + * @return the date the change was authored on. + * @throws IOException if the information was not already fetched and an attempt at fetching the information failed. + */ + public Date getAuthoredDate() throws IOException { + return getCommitShortInfo().getAuthoredDate(); + } + public GHUser getCommitter() throws IOException { return resolveUser(committer); } + /** + * Gets the date the change was committed on. + * + * @return the date the change was committed on. + * @throws IOException if the information was not already fetched and an attempt at fetching the information failed. + */ + public Date getCommitDate() throws IOException { + return getCommitShortInfo().getCommitDate(); + } + private GHUser resolveUser(User author) throws IOException { if (author==null || author.login==null) return null; return owner.root.getUser(author.login);