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 8b34696

Browse filesBrowse files
authored
Merge pull request hub4j#300 from stephenc/commit-dates
Expose the commit dates
2 parents df963cb + 50b47fb commit 8b34696
Copy full SHA for 8b34696

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

+29
-1
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
+29-1Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
44
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
5-
65
import java.io.IOException;
76
import java.net.URL;
87
import java.util.AbstractList;
98
import java.util.ArrayList;
109
import java.util.Collections;
10+
import java.util.Date;
1111
import java.util.List;
1212

1313
/**
@@ -42,11 +42,19 @@ public GitUser getAuthor() {
4242
return author;
4343
}
4444

45+
public Date getAuthoredDate() {
46+
return GitHub.parseDate(author.date);
47+
}
48+
4549
@WithBridgeMethods(value = GHAuthor.class, castRequired = true)
4650
public GitUser getCommitter() {
4751
return committer;
4852
}
4953

54+
public Date getCommitDate() {
55+
return GitHub.parseDate(author.date);
56+
}
57+
5058
/**
5159
* Commit message.
5260
*/
@@ -63,6 +71,7 @@ public int getCommentCount() {
6371
* @deprecated Use {@link GitUser} instead.
6472
*/
6573
public static class GHAuthor extends GitUser {
74+
private String date;
6675
}
6776

6877
public static class Stats {
@@ -272,10 +281,29 @@ public GHUser getAuthor() throws IOException {
272281
return resolveUser(author);
273282
}
274283

284+
/**
285+
* Gets the date the change was authored on.
286+
* @return the date the change was authored on.
287+
* @throws IOException if the information was not already fetched and an attempt at fetching the information failed.
288+
*/
289+
public Date getAuthoredDate() throws IOException {
290+
return getCommitShortInfo().getAuthoredDate();
291+
}
292+
275293
public GHUser getCommitter() throws IOException {
276294
return resolveUser(committer);
277295
}
278296

297+
/**
298+
* Gets the date the change was committed on.
299+
*
300+
* @return the date the change was committed on.
301+
* @throws IOException if the information was not already fetched and an attempt at fetching the information failed.
302+
*/
303+
public Date getCommitDate() throws IOException {
304+
return getCommitShortInfo().getCommitDate();
305+
}
306+
279307
private GHUser resolveUser(User author) throws IOException {
280308
if (author==null || author.login==null) return null;
281309
return owner.root.getUser(author.login);

0 commit comments

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