public static BasicFileAttributes buildBasicFileAttributes(final Git git, final String branchName, final String path) {
long createDate = Long.MAX_VALUE;
long lastModified = Long.MIN_VALUE;
final JGitPathInfo pathInfo = resolvePath(git, branchName, path);
if (pathInfo == null) {
throw new NoSuchFileException(path);
}
final String gPath = fixPath(path);
try {
final LogCommand logCommand = git.log().add(getBranch(git, branchName).getObjectId());
if (!gPath.isEmpty()) {
logCommand.addPath(gPath);
}
for (final RevCommit commit : logCommand.call()) {
if (commit.getAuthorIdent().getWhen().getTime() < createDate) {
createDate = commit.getAuthorIdent().getWhen().getTime();
}
if (commit.getAuthorIdent().getWhen().getTime() > lastModified) {
lastModified = commit.getAuthorIdent().getWhen().getTime();
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return new JGitFileAttributes(pathInfo.getObjectId() == null ? null : pathInfo.getObjectId().toString(), new FileTimeImpl(lastModified), new FileTimeImpl(createDate), pathInfo.getSize(), pathInfo.getPathType().equals(PathType.FILE), pathInfo.getPathType().equals(PathType.DIRECTORY));
}