get date and author

This commit is contained in:
Anton Romanov 2021-03-09 15:54:59 +04:00
parent 199e9a7eb1
commit 7b8c22b410
2 changed files with 10 additions and 2 deletions

View File

@ -7,8 +7,11 @@ public class Commit {
private Date date; private Date date;
private String author; private String author;
public Commit(String message) { public Commit(String message, String author, Date date) {
this.message = message; this.message = message;
this.author = author;
this.date = date;
} }
public String getMessage() { public String getMessage() {

View File

@ -11,7 +11,9 @@ import org.springframework.stereotype.Service;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import static org.apache.logging.log4j.util.Strings.isBlank; import static org.apache.logging.log4j.util.Strings.isBlank;
@ -68,7 +70,10 @@ public class GitRepositoryService {
List<Commit> list = new ArrayList<>(); List<Commit> list = new ArrayList<>();
for (RevCommit commit : commits) { 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); list.add(fullMessage);
} }