| | |
| | | */
|
| | | package com.gitblit.wicket.panels;
|
| | |
|
| | | import java.util.Collections;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
| | | import org.apache.wicket.markup.repeater.data.DataView;
|
| | | import org.apache.wicket.markup.repeater.data.ListDataProvider;
|
| | | import org.apache.wicket.model.StringResourceModel;
|
| | | import org.eclipse.jgit.diff.DiffEntry.ChangeType;
|
| | | import org.eclipse.jgit.lib.ObjectId;
|
| | | import org.eclipse.jgit.lib.Repository;
|
| | | import org.eclipse.jgit.revwalk.RevCommit;
|
| | | import org.eclipse.jgit.treewalk.TreeWalk;
|
| | | import org.eclipse.jgit.treewalk.filter.PathFilterGroup;
|
| | |
|
| | | import com.gitblit.Constants;
|
| | | import com.gitblit.GitBlit;
|
| | |
| | | private boolean hasMore;
|
| | |
|
| | | public HistoryPanel(String wicketId, final String repositoryName, final String objectId,
|
| | | final String path, Repository r, int limit, int pageOffset) {
|
| | | final String path, Repository r, int limit, int pageOffset, boolean showRemoteRefs) {
|
| | | super(wicketId);
|
| | | boolean pageResults = limit <= 0;
|
| | | int itemsPerPage = GitBlit.getInteger(Keys.web.itemsPerPage, 50);
|
| | |
| | | break;
|
| | | }
|
| | | }
|
| | | if (matchingPath == null) {
|
| | | // path not in commit
|
| | | // manually locate path in tree
|
| | | TreeWalk tw = new TreeWalk(r);
|
| | | tw.reset();
|
| | | tw.setRecursive(true);
|
| | | try {
|
| | | tw.addTree(commit.getTree());
|
| | | tw.setFilter(PathFilterGroup.createFromStrings(Collections.singleton(path)));
|
| | | while (tw.next()) {
|
| | | matchingPath = new PathChangeModel(tw.getPathString(), tw.getPathString(), 0, tw
|
| | | .getRawMode(0), tw.getObjectId(0).getName(), commit.getId().getName(),
|
| | | ChangeType.MODIFY);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | } finally {
|
| | | tw.release();
|
| | | }
|
| | | }
|
| | | |
| | | final boolean isTree = matchingPath == null ? true : matchingPath.isTree();
|
| | |
|
| | | final Map<ObjectId, List<RefModel>> allRefs = JGitUtils.getAllRefs(r);
|
| | | final Map<ObjectId, List<RefModel>> allRefs = JGitUtils.getAllRefs(r, showRemoteRefs);
|
| | | List<RevCommit> commits;
|
| | | if (pageResults) {
|
| | | // Paging result set
|
| | |
| | | // breadcrumbs
|
| | | add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, path, objectId));
|
| | |
|
| | | final int hashLen = GitBlit.getInteger(Keys.web.shortCommitIdLength, 6);
|
| | | ListDataProvider<RevCommit> dp = new ListDataProvider<RevCommit>(commits);
|
| | | DataView<RevCommit> logView = new DataView<RevCommit>("commit", dp) {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
| | | final RevCommit entry = item.getModelObject();
|
| | | final Date date = JGitUtils.getCommitDate(entry);
|
| | |
|
| | | item.add(WicketUtils.createDateLabel("commitDate", date, getTimeZone()));
|
| | | item.add(WicketUtils.createDateLabel("commitDate", date, getTimeZone(), getTimeUtils()));
|
| | |
|
| | | // author search link
|
| | | String author = entry.getAuthorIdent().getName();
|
| | |
| | | setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR);
|
| | | item.add(authorLink);
|
| | |
|
| | | // commit hash link
|
| | | LinkPanel commitHash = new LinkPanel("commitHash", null, entry.getName().substring(0, hashLen),
|
| | | CommitPage.class, WicketUtils.newObjectParameter(
|
| | | repositoryName, entry.getName()));
|
| | | WicketUtils.setCssClass(commitHash, "sha1");
|
| | | WicketUtils.setHtmlTooltip(commitHash, entry.getName());
|
| | | item.add(commitHash);
|
| | | |
| | | // merge icon
|
| | | if (entry.getParentCount() > 1) {
|
| | | item.add(WicketUtils.newImage("commitIcon", "commit_merge_16x16.png"));
|