From 7b8c22b4101a4fa595b9d82a5bd901dc510ed38f Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Tue, 9 Mar 2021 15:54:59 +0400 Subject: [PATCH] get date and author --- src/main/java/ru/ulstu/extractor/Commit.java | 5 ++++- src/main/java/ru/ulstu/extractor/GitRepositoryService.java | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/ulstu/extractor/Commit.java b/src/main/java/ru/ulstu/extractor/Commit.java index 328a5e8..463525a 100644 --- a/src/main/java/ru/ulstu/extractor/Commit.java +++ b/src/main/java/ru/ulstu/extractor/Commit.java @@ -7,8 +7,11 @@ public class Commit { private Date date; private String author; - public Commit(String message) { + public Commit(String message, String author, Date date) { this.message = message; + this.author = author; + this.date = date; + } public String getMessage() { diff --git a/src/main/java/ru/ulstu/extractor/GitRepositoryService.java b/src/main/java/ru/ulstu/extractor/GitRepositoryService.java index 1d02866..b53e8ec 100644 --- a/src/main/java/ru/ulstu/extractor/GitRepositoryService.java +++ b/src/main/java/ru/ulstu/extractor/GitRepositoryService.java @@ -11,7 +11,9 @@ import org.springframework.stereotype.Service; import java.io.File; import java.io.IOException; import java.nio.file.Path; +import java.time.Instant; import java.util.ArrayList; +import java.util.Date; import java.util.List; import static org.apache.logging.log4j.util.Strings.isBlank; @@ -68,7 +70,10 @@ public class GitRepositoryService { List list = new ArrayList<>(); for (RevCommit commit : commits) { - Commit fullMessage = new Commit(commit.getFullMessage()); + Commit fullMessage = new Commit( + commit.getFullMessage(), + commit.getAuthorIdent().getName(), + Date.from(Instant.ofEpochSecond(commit.getCommitTime()))); list.add(fullMessage); }