From: James Moger Date: Fri, 18 Sep 2015 15:23:42 +0000 (-0400) Subject: Use author date to be consistent with other tools (fixes #919) X-Git-Tag: v1.7.0~1^2~21 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a592329a82d0a85d33abcc63f08df20b79e8e4f7;p=gitblit.git Use author date to be consistent with other tools (fixes #919) --- diff --git a/releases.moxie b/releases.moxie index 667154df..5fdb64ca 100644 --- a/releases.moxie +++ b/releases.moxie @@ -24,6 +24,7 @@ r27: { - Use release name as root directory in Gitblit GO artifacts (ticket-109) - Split gitblit.properties into gitblit.properties & defaults.properties (ticket-110) - Show team type in teams page (pr-217, ticket-168) + - Use author date to be consistent with other tools (pr-919) additions: - Add GitHub Octicons (ticket-106) - Support for chain-loading properties files (ticket-110) diff --git a/src/main/java/com/gitblit/models/RefModel.java b/src/main/java/com/gitblit/models/RefModel.java index 02ba1302..4d9a0c65 100644 --- a/src/main/java/com/gitblit/models/RefModel.java +++ b/src/main/java/com/gitblit/models/RefModel.java @@ -58,9 +58,9 @@ public class RefModel implements Serializable, Comparable { } } else if (referencedObject instanceof RevCommit) { RevCommit commit = (RevCommit) referencedObject; - PersonIdent committer = commit.getCommitterIdent(); - if (committer != null) { - date = committer.getWhen(); + PersonIdent author = commit.getAuthorIdent(); + if (author != null) { + date = author.getWhen(); } else { date = JGitUtils.getCommitDate(commit); } diff --git a/src/main/java/com/gitblit/utils/JGitUtils.java b/src/main/java/com/gitblit/utils/JGitUtils.java index 356a796c..c3d02073 100644 --- a/src/main/java/com/gitblit/utils/JGitUtils.java +++ b/src/main/java/com/gitblit/utils/JGitUtils.java @@ -30,7 +30,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.regex.Pattern; -import com.google.common.base.Strings; import org.apache.commons.io.filefilter.TrueFileFilter; import org.eclipse.jgit.api.CloneCommand; import org.eclipse.jgit.api.FetchCommand; @@ -91,6 +90,7 @@ import com.gitblit.models.PathModel; import com.gitblit.models.PathModel.PathChangeModel; import com.gitblit.models.RefModel; import com.gitblit.models.SubmoduleModel; +import com.google.common.base.Strings; /** * Collection of static methods for retrieving information from a repository. @@ -691,7 +691,10 @@ public class JGitUtils { if (commit == null) { return new Date(0); } - return commit.getAuthorIdent().getWhen(); + if (commit.getAuthorIdent() != null) { + return commit.getAuthorIdent().getWhen(); + } + return getCommitDate(commit); } /** diff --git a/src/main/java/com/gitblit/utils/MetricUtils.java b/src/main/java/com/gitblit/utils/MetricUtils.java index 47031021..62427e6d 100644 --- a/src/main/java/com/gitblit/utils/MetricUtils.java +++ b/src/main/java/com/gitblit/utils/MetricUtils.java @@ -136,7 +136,7 @@ public class MetricUtils { Iterable revlog = revWalk; for (RevCommit rev : revlog) { - Date d = JGitUtils.getCommitDate(rev); + Date d = JGitUtils.getAuthorDate(rev); String p = df.format(d); if (!metricMap.containsKey(p)) { metricMap.put(p, new Metric(p)); diff --git a/src/main/java/com/gitblit/wicket/pages/TicketPage.java b/src/main/java/com/gitblit/wicket/pages/TicketPage.java index 2dbc8e9d..8bf5c6d9 100644 --- a/src/main/java/com/gitblit/wicket/pages/TicketPage.java +++ b/src/main/java/com/gitblit/wicket/pages/TicketPage.java @@ -88,10 +88,10 @@ import com.gitblit.utils.TimeUtils; import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.TicketsUI; import com.gitblit.wicket.WicketUtils; +import com.gitblit.wicket.panels.AvatarImage; import com.gitblit.wicket.panels.BasePanel.JavascriptTextPrompt; import com.gitblit.wicket.panels.CommentPanel; import com.gitblit.wicket.panels.DiffStatPanel; -import com.gitblit.wicket.panels.AvatarImage; import com.gitblit.wicket.panels.IconAjaxLink; import com.gitblit.wicket.panels.LinkPanel; import com.gitblit.wicket.panels.ShockWaveComponent; @@ -823,7 +823,7 @@ public class TicketPage extends RepositoryPage { item.add(new LinkPanel("diff", "link", getString("gb.diff"), CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, commit.getName()), true)); item.add(new Label("title", StringUtils.trimString(commit.getShortMessage(), Constants.LEN_SHORTLOG_REFS))); - item.add(WicketUtils.createDateLabel("commitDate", JGitUtils.getCommitDate(commit), GitBlitWebSession + item.add(WicketUtils.createDateLabel("commitDate", JGitUtils.getAuthorDate(commit), GitBlitWebSession .get().getTimezone(), getTimeUtils(), false)); item.add(new DiffStatPanel("commitDiffStat", 0, 0, true)); } diff --git a/src/main/java/com/gitblit/wicket/panels/HistoryPanel.java b/src/main/java/com/gitblit/wicket/panels/HistoryPanel.java index 5233f7c9..a3f127b1 100644 --- a/src/main/java/com/gitblit/wicket/panels/HistoryPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/HistoryPanel.java @@ -160,7 +160,7 @@ public class HistoryPanel extends BasePanel { @Override public void populateItem(final Item item) { final RevCommit entry = item.getModelObject(); - final Date date = JGitUtils.getCommitDate(entry); + final Date date = JGitUtils.getAuthorDate(entry); item.add(WicketUtils.createDateLabel("commitDate", date, getTimeZone(), getTimeUtils())); diff --git a/src/main/java/com/gitblit/wicket/panels/LogPanel.java b/src/main/java/com/gitblit/wicket/panels/LogPanel.java index 16fc746e..e9d240d0 100644 --- a/src/main/java/com/gitblit/wicket/panels/LogPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/LogPanel.java @@ -109,7 +109,7 @@ public class LogPanel extends BasePanel { @Override public void populateItem(final Item item) { final RevCommit entry = item.getModelObject(); - final Date date = JGitUtils.getCommitDate(entry); + final Date date = JGitUtils.getAuthorDate(entry); final boolean isMerge = entry.getParentCount() > 1; item.add(WicketUtils.createDateLabel("commitDate", date, getTimeZone(), getTimeUtils())); diff --git a/src/main/java/com/gitblit/wicket/panels/SearchPanel.java b/src/main/java/com/gitblit/wicket/panels/SearchPanel.java index 5d0b2de1..09322bc7 100644 --- a/src/main/java/com/gitblit/wicket/panels/SearchPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/SearchPanel.java @@ -86,7 +86,7 @@ public class SearchPanel extends BasePanel { @Override public void populateItem(final Item item) { final RevCommit entry = item.getModelObject(); - final Date date = JGitUtils.getCommitDate(entry); + final Date date = JGitUtils.getAuthorDate(entry); item.add(WicketUtils.createDateLabel("commitDate", date, getTimeZone(), getTimeUtils()));