From b2775fefaafb0ce89094bdd4bb5308dbb90f487b Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 19 Feb 2014 09:04:55 -0500
Subject: [PATCH] Merge commit 'refs/tickets/08/8/3' of https://dev.gitblit.com/r/gitblit
---
src/main/java/com/gitblit/wicket/panels/DigestsPanel.java | 62 +++++++++++++++---------------
1 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/src/main/java/com/gitblit/wicket/panels/DigestsPanel.java b/src/main/java/com/gitblit/wicket/panels/DigestsPanel.java
index 0f380a4..318e74c 100644
--- a/src/main/java/com/gitblit/wicket/panels/DigestsPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/DigestsPanel.java
@@ -28,9 +28,9 @@
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
+import org.eclipse.jgit.lib.PersonIdent;
import com.gitblit.Constants;
-import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.DailyLogEntry;
import com.gitblit.models.RepositoryCommit;
@@ -42,32 +42,32 @@
import com.gitblit.wicket.pages.SummaryPage;
import com.gitblit.wicket.pages.TagPage;
import com.gitblit.wicket.pages.TreePage;
-import com.gitblit.wicket.pages.UserPage;
public class DigestsPanel extends BasePanel {
private static final long serialVersionUID = 1L;
private final boolean hasChanges;
-
+
private boolean hasMore;
public DigestsPanel(String wicketId, List<DailyLogEntry> digests) {
super(wicketId);
hasChanges = digests.size() > 0;
- final int hashLen = GitBlit.getInteger(Keys.web.shortCommitIdLength, 6);
+ final int hashLen = app().settings().getInteger(Keys.web.shortCommitIdLength, 6);
- String dateFormat = GitBlit.getString(Keys.web.datestampLongFormat, "EEEE, MMMM d, yyyy");
+ String dateFormat = app().settings().getString(Keys.web.datestampLongFormat, "EEEE, MMMM d, yyyy");
final TimeZone timezone = getTimeZone();
final DateFormat df = new SimpleDateFormat(dateFormat);
df.setTimeZone(timezone);
final Calendar cal = Calendar.getInstance(timezone);
-
+
ListDataProvider<DailyLogEntry> dp = new ListDataProvider<DailyLogEntry>(digests);
DataView<DailyLogEntry> pushView = new DataView<DailyLogEntry>("change", dp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<DailyLogEntry> logItem) {
final DailyLogEntry change = logItem.getModelObject();
String fullRefName = change.getChangedRefs().get(0);
@@ -79,7 +79,7 @@
shortRefName = shortRefName.substring(Constants.R_TAGS.length());
isTag = true;
}
-
+
String fuzzydate;
TimeUtils tu = getTimeUtils();
Date pushDate = change.date;
@@ -111,19 +111,18 @@
}
logItem.add(changeIcon);
- if (!isTag) {
- logItem.add(new Label("whoChanged").setVisible(false));
- } else {
- if (change.user.username.equals(change.user.emailAddress) && change.user.emailAddress.indexOf('@') > -1) {
- // username is an email address can not link - 1.2.1 push log bug
- logItem.add(new Label("whoChanged", change.user.getDisplayName()));
+ if (isTag) {
+ // tags are special
+ PersonIdent ident = change.getCommits().get(0).getAuthorIdent();
+ if (!StringUtils.isEmpty(ident.getName())) {
+ logItem.add(new Label("whoChanged", ident.getName()));
} else {
- // link to user account page
- logItem.add(new LinkPanel("whoChanged", null, change.user.getDisplayName(),
- UserPage.class, WicketUtils.newUsernameParameter(change.user.username)));
+ logItem.add(new Label("whoChanged", ident.getEmailAddress()));
}
+ } else {
+ logItem.add(new Label("whoChanged").setVisible(false));
}
-
+
String preposition = "gb.of";
boolean isDelete = false;
String what;
@@ -151,17 +150,17 @@
break;
default:
what = MessageFormat.format(change.getCommitCount() > 1 ? getString("gb.commitsTo") : getString("gb.oneCommitTo"), change.getCommitCount());
-
+
if (change.getAuthorCount() == 1) {
by = MessageFormat.format(getString("gb.byOneAuthor"), change.getAuthorIdent().getName());
} else {
- by = MessageFormat.format(getString("gb.byNAuthors"), change.getAuthorCount());
+ by = MessageFormat.format(getString("gb.byNAuthors"), change.getAuthorCount());
}
break;
}
logItem.add(new Label("whatChanged", what));
logItem.add(new Label("byAuthors", by).setVisible(!StringUtils.isEmpty(by)));
-
+
if (isDelete) {
// can't link to deleted ref
logItem.add(new Label("refChanged", shortRefName));
@@ -174,19 +173,19 @@
logItem.add(new LinkPanel("refChanged", null, shortRefName,
TreePage.class, WicketUtils.newObjectParameter(change.repository, fullRefName)));
}
-
+
// to/from/etc
logItem.add(new Label("repoPreposition", getString(preposition)));
String repoName = StringUtils.stripDotGit(change.repository);
logItem.add(new LinkPanel("repoChanged", null, repoName,
SummaryPage.class, WicketUtils.newRepositoryParameter(change.repository)));
-
+
int maxCommitCount = 5;
List<RepositoryCommit> commits = change.getCommits();
if (commits.size() > maxCommitCount) {
- commits = new ArrayList<RepositoryCommit>(commits.subList(0, maxCommitCount));
+ commits = new ArrayList<RepositoryCommit>(commits.subList(0, maxCommitCount));
}
-
+
// compare link
String compareLinkText = null;
if ((change.getCommitCount() <= maxCommitCount) && (change.getCommitCount() > 1)) {
@@ -202,20 +201,21 @@
String startRangeId = change.getOldId(fullRefName);
logItem.add(new LinkPanel("compareLink", null, compareLinkText, ComparePage.class, WicketUtils.newRangeParameter(change.repository, startRangeId, endRangeId)));
}
-
- final boolean showSwatch = GitBlit.getBoolean(Keys.web.repositoryListSwatches, true);
-
+
+ final boolean showSwatch = app().settings().getBoolean(Keys.web.repositoryListSwatches, true);
+
ListDataProvider<RepositoryCommit> cdp = new ListDataProvider<RepositoryCommit>(commits);
DataView<RepositoryCommit> commitsView = new DataView<RepositoryCommit>("commit", cdp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<RepositoryCommit> commitItem) {
final RepositoryCommit commit = commitItem.getModelObject();
// author gravatar
commitItem.add(new GravatarImage("commitAuthor", commit.getAuthorIdent().getName(),
commit.getAuthorIdent().getEmailAddress(), null, 16, false, false));
-
+
// merge icon
if (commit.getParentCount() > 1) {
commitItem.add(WicketUtils.newImage("commitIcon", "commit_merge_16x16.png"));
@@ -246,7 +246,7 @@
WicketUtils.setCssClass(commitHash, "shortsha1");
WicketUtils.setHtmlTooltip(commitHash, commit.getName());
commitItem.add(commitHash);
-
+
if (showSwatch) {
// set repository color
String color = StringUtils.getColor(StringUtils.stripDotGit(change.repository));
@@ -258,14 +258,14 @@
logItem.add(commitsView);
}
};
-
+
add(pushView);
}
public boolean hasMore() {
return hasMore;
}
-
+
public boolean hideIfEmpty() {
setVisible(hasChanges);
return hasChanges;
--
Gitblit v1.9.1