Skip to content

Commit

Permalink
Merge pull request #300 from stephenc/commit-dates
Browse files Browse the repository at this point in the history
Expose the commit dates
  • Loading branch information
kohsuke authored Oct 24, 2016
2 parents df963cb + 50b47fb commit 8b34696
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/main/java/org/kohsuke/github/GHCommit.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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.
*/
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 8b34696

Please sign in to comment.