| | |
| | | import org.apache.wicket.markup.repeater.data.DataView;
|
| | | import org.apache.wicket.markup.repeater.data.ListDataProvider;
|
| | | import org.eclipse.jgit.lib.Constants;
|
| | | import org.eclipse.jgit.lib.ObjectId;
|
| | | import org.eclipse.jgit.revwalk.RevCommit;
|
| | |
|
| | | import com.gitblit.GitBlit;
|
| | |
| | | import com.gitblit.utils.DiffUtils;
|
| | | import com.gitblit.utils.JGitUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.wicket.CacheControl;
|
| | | import com.gitblit.wicket.CacheControl.LastModified;
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | | import com.gitblit.wicket.panels.CommitHeaderPanel;
|
| | | import com.gitblit.wicket.panels.LinkPanel;
|
| | | import com.gitblit.wicket.panels.PathBreadcrumbsPanel;
|
| | |
|
| | | @CacheControl(LastModified.BOOT)
|
| | | public class BlamePage extends RepositoryPage {
|
| | |
|
| | | public BlamePage(PageParameters params) {
|
| | |
| | | "EEEE, MMMM d, yyyy HH:mm Z");
|
| | | final DateFormat df = new SimpleDateFormat(format);
|
| | | df.setTimeZone(getTimeZone());
|
| | | |
| | |
|
| | | PathModel pathModel = null;
|
| | | List<PathModel> paths = JGitUtils.getFilesInPath(getRepository(), StringUtils.getRootPath(blobPath), commit);
|
| | | for (PathModel path : paths) {
|
| | |
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | if (pathModel == null) {
|
| | | add(new Label("annotation").setVisible(false));
|
| | | add(new Label("missingBlob", missingBlob(blobPath, commit)).setEscapeModelStrings(false));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | add(new Label("missingBlob").setVisible(false));
|
| | | |
| | |
|
| | | List<AnnotatedLine> lines = DiffUtils.blame(getRepository(), blobPath, objectId);
|
| | | ListDataProvider<AnnotatedLine> blameDp = new ListDataProvider<AnnotatedLine>(lines);
|
| | | DataView<AnnotatedLine> blameView = new DataView<AnnotatedLine>("annotation", blameDp) {
|
| | |
| | | private int count;
|
| | | private String lastCommitId = "";
|
| | | private boolean showInitials = true;
|
| | | private String zeroId = ObjectId.zeroId().getName();
|
| | |
|
| | | @Override
|
| | | public void populateItem(final Item<AnnotatedLine> item) {
|
| | | AnnotatedLine entry = item.getModelObject();
|
| | | item.add(new Label("line", "" + entry.lineNumber));
|
| | |
| | | if (!lastCommitId.equals(entry.commitId)) {
|
| | | lastCommitId = entry.commitId;
|
| | | count++;
|
| | | // show the link for first line
|
| | | LinkPanel commitLink = new LinkPanel("commit", null,
|
| | | getShortObjectId(entry.commitId), CommitPage.class,
|
| | | newCommitParameter(entry.commitId));
|
| | | WicketUtils.setHtmlTooltip(commitLink,
|
| | | MessageFormat.format("{0}, {1}", entry.author, df.format(entry.when)));
|
| | | item.add(commitLink);
|
| | | showInitials = true;
|
| | | if (zeroId.equals(entry.commitId)) {
|
| | | // unknown commit
|
| | | item.add(new Label("commit", "<?>"));
|
| | | showInitials = false;
|
| | | } else {
|
| | | // show the link for first line
|
| | | LinkPanel commitLink = new LinkPanel("commit", null,
|
| | | getShortObjectId(entry.commitId), CommitPage.class,
|
| | | newCommitParameter(entry.commitId));
|
| | | WicketUtils.setHtmlTooltip(commitLink,
|
| | | MessageFormat.format("{0}, {1}", entry.author, df.format(entry.when)));
|
| | | item.add(commitLink);
|
| | | showInitials = true;
|
| | | }
|
| | | } else {
|
| | | if (showInitials) {
|
| | | showInitials = false;
|
| | |
| | | protected String getPageName() {
|
| | | return getString("gb.blame");
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | protected Class<? extends BasePage> getRepoNavPageClass() {
|
| | | return TreePage.class;
|
| | | }
|
| | | |
| | |
|
| | | protected String missingBlob(String blobPath, RevCommit commit) {
|
| | | StringBuilder sb = new StringBuilder();
|
| | | sb.append("<div class=\"alert alert-error\">");
|