| | |
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.TimeZone;
|
| | |
|
| | | import org.eclipse.jgit.lib.Constants;
|
| | | import org.eclipse.jgit.lib.ObjectId;
|
| | | import org.eclipse.jgit.lib.Repository;
|
| | | import org.eclipse.jgit.revwalk.RevCommit;
|
| | |
| | | * if null or empty, HEAD is assumed.
|
| | | * @param includeTotal
|
| | | * @param dateFormat
|
| | | * @param timezone
|
| | | * @return list of metrics
|
| | | */
|
| | | public static List<Metric> getDateMetrics(Repository repository, String objectId,
|
| | | boolean includeTotal, String dateFormat) {
|
| | | boolean includeTotal, String dateFormat, TimeZone timezone) {
|
| | | Metric total = new Metric("TOTAL");
|
| | | final Map<String, Metric> metricMap = new HashMap<String, Metric>();
|
| | |
|
| | |
| | | } else {
|
| | | branchObject = repository.resolve(objectId);
|
| | | }
|
| | | |
| | |
|
| | | revWalk = new RevWalk(repository);
|
| | | RevCommit lastCommit = revWalk.parseCommit(branchObject);
|
| | | revWalk.markStart(lastCommit);
|
| | |
| | | DateFormat df;
|
| | | if (StringUtils.isEmpty(dateFormat)) {
|
| | | // dynamically determine date format
|
| | | RevCommit firstCommit = JGitUtils.getFirstCommit(repository, branchObject.getName());
|
| | | RevCommit firstCommit = JGitUtils.getFirstCommit(repository,
|
| | | branchObject.getName());
|
| | | int diffDays = (lastCommit.getCommitTime() - firstCommit.getCommitTime())
|
| | | / (60 * 60 * 24);
|
| | | total.duration = diffDays;
|
| | |
| | | // use specified date format
|
| | | df = new SimpleDateFormat(dateFormat);
|
| | | }
|
| | | df.setTimeZone(timezone);
|
| | |
|
| | | Iterable<RevCommit> revlog = revWalk;
|
| | | for (RevCommit rev : revlog) {
|