From ed9717d4e8d36bdc37a48bb0bdf8a000a1362127 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Mon, 30 Sep 2013 10:10:46 -0400
Subject: [PATCH] Remove issue artifacts from classes missed in previous purge
---
src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java | 97 +++++++++++++++++++++++-------------------------
1 files changed, 47 insertions(+), 50 deletions(-)
diff --git a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
index cfdb863..3bd759d 100644
--- a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
@@ -15,8 +15,8 @@
*/
package com.gitblit.wicket.pages;
-import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.apache.wicket.PageParameters;
@@ -30,18 +30,26 @@
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
+import com.gitblit.Constants;
import com.gitblit.GitBlit;
-import com.gitblit.Keys;
+import com.gitblit.models.GitNote;
import com.gitblit.models.PathModel.PathChangeModel;
import com.gitblit.models.SubmoduleModel;
import com.gitblit.utils.DiffUtils;
+import com.gitblit.utils.DiffUtils.DiffOutput;
import com.gitblit.utils.DiffUtils.DiffOutputType;
import com.gitblit.utils.JGitUtils;
+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.CommitLegendPanel;
+import com.gitblit.wicket.panels.DiffStatPanel;
+import com.gitblit.wicket.panels.GravatarImage;
import com.gitblit.wicket.panels.LinkPanel;
+import com.gitblit.wicket.panels.RefsPanel;
+@CacheControl(LastModified.BOOT)
public class CommitDiffPage extends RepositoryPage {
public CommitDiffPage(PageParameters params) {
@@ -49,32 +57,9 @@
Repository r = getRepository();
- DiffOutputType diffType = DiffOutputType.forName(GitBlit.getString(Keys.web.diffStyle,
- DiffOutputType.GITBLIT.name()));
+ RevCommit commit = getCommit();
- RevCommit commit = null, otherCommit = null;
-
- if( objectId.contains("..") )
- {
- String[] parts = objectId.split("\\.\\.");
- commit = getCommit(r, parts[0]);
- otherCommit = getCommit(r, parts[1]);
- }
- else
- {
- commit = getCommit();
- }
-
- String diff;
-
- if(otherCommit == null)
- {
- diff = DiffUtils.getCommitDiff(r, commit, diffType);
- }
- else
- {
- diff = DiffUtils.getDiff(r, commit, otherCommit, diffType);
- }
+ final DiffOutput diff = DiffUtils.getCommitDiff(r, commit, DiffOutputType.HTML);
List<String> parents = new ArrayList<String>();
if (commit.getParentCount() > 0) {
@@ -97,20 +82,40 @@
add(new CommitHeaderPanel("commitHeader", repositoryName, commit));
+ // add commit diffstat
+ int insertions = 0;
+ int deletions = 0;
+ for (PathChangeModel pcm : diff.stat.paths) {
+ insertions += pcm.insertions;
+ deletions += pcm.deletions;
+ }
+ add(new DiffStatPanel("diffStat", insertions, deletions));
+
+ addFullText("fullMessage", commit.getFullMessage());
+
+ // git notes
+ List<GitNote> notes = JGitUtils.getNotesOnCommit(r, commit);
+ ListDataProvider<GitNote> notesDp = new ListDataProvider<GitNote>(notes);
+ DataView<GitNote> notesView = new DataView<GitNote>("notes", notesDp) {
+ private static final long serialVersionUID = 1L;
+
+ public void populateItem(final Item<GitNote> item) {
+ GitNote entry = item.getModelObject();
+ item.add(new RefsPanel("refName", repositoryName, Arrays.asList(entry.notesRef)));
+ item.add(createPersonPanel("authorName", entry.notesRef.getAuthorIdent(),
+ Constants.SearchType.AUTHOR));
+ item.add(new GravatarImage("noteAuthorAvatar", entry.notesRef.getAuthorIdent()));
+ item.add(WicketUtils.createTimestampLabel("authorDate", entry.notesRef
+ .getAuthorIdent().getWhen(), getTimeZone(), getTimeUtils()));
+ item.add(new Label("noteContent", GitBlit.self().processPlainCommitMessage(repositoryName,
+ entry.content)).setEscapeModelStrings(false));
+ }
+ };
+ add(notesView.setVisible(notes.size() > 0));
+
// changed paths list
- List<PathChangeModel> paths;
-
- if( otherCommit == null )
- {
- paths = JGitUtils.getFilesInCommit(r, commit);
- }
- else
- {
- paths = JGitUtils.getFilesInCommit(r, otherCommit);
- }
-
- add(new CommitLegendPanel("commitLegend", paths));
- ListDataProvider<PathChangeModel> pathsDp = new ListDataProvider<PathChangeModel>(paths);
+ add(new CommitLegendPanel("commitLegend", diff.stat.paths));
+ ListDataProvider<PathChangeModel> pathsDp = new ListDataProvider<PathChangeModel>(diff.stat.paths);
DataView<PathChangeModel> pathsView = new DataView<PathChangeModel>("changedPath", pathsDp) {
private static final long serialVersionUID = 1L;
int counter;
@@ -121,6 +126,7 @@
WicketUtils.setChangeTypeCssClass(changeType, entry.changeType);
setChangeTypeTooltip(changeType, entry.changeType);
item.add(changeType);
+ item.add(new DiffStatPanel("diffStat", entry.insertions, entry.deletions, true));
boolean hasSubmodule = false;
String submodulePath = null;
@@ -176,7 +182,7 @@
}
};
add(pathsView);
- add(new Label("diffText", diff).setEscapeModelStrings(false));
+ add(new Label("diffText", diff.content).setEscapeModelStrings(false));
}
@Override
@@ -187,14 +193,5 @@
@Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return LogPage.class;
- }
-
- private RevCommit getCommit(Repository r, String rev)
- {
- RevCommit otherCommit = JGitUtils.getCommit(r, rev);
- if (otherCommit == null) {
- error(MessageFormat.format(getString("gb.failedToFindCommit"), rev, repositoryName, getPageName()), true);
- }
- return otherCommit;
}
}
--
Gitblit v1.9.1