]> source.dussan.org Git - gitblit.git/commitdiff
Blame support finished, requires JGit 1.0.0. Checkstyle. Findbugs.
authorJames Moger <james.moger@gitblit.com>
Thu, 9 Jun 2011 00:48:07 +0000 (20:48 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 9 Jun 2011 00:48:07 +0000 (20:48 -0400)
28 files changed:
src/com/gitblit/models/AnnotatedLine.java [new file with mode: 0644]
src/com/gitblit/models/GitNote.java
src/com/gitblit/models/RefModel.java
src/com/gitblit/utils/DiffUtils.java
src/com/gitblit/utils/JGitUtils.java
src/com/gitblit/utils/MetricUtils.java
src/com/gitblit/utils/StringUtils.java
src/com/gitblit/utils/TimeUtils.java
src/com/gitblit/wicket/GitBlitWebApp.java
src/com/gitblit/wicket/WicketUtils.java
src/com/gitblit/wicket/pages/BlamePage.html
src/com/gitblit/wicket/pages/BlamePage.java
src/com/gitblit/wicket/pages/BlobPage.java
src/com/gitblit/wicket/pages/CommitDiffPage.java
src/com/gitblit/wicket/pages/CommitPage.java
src/com/gitblit/wicket/pages/EditRepositoryPage.java
src/com/gitblit/wicket/pages/MetricsPage.java
src/com/gitblit/wicket/pages/RepositoryPage.java
src/com/gitblit/wicket/pages/SummaryPage.java
src/com/gitblit/wicket/panels/CommitHeaderPanel.java
src/com/gitblit/wicket/panels/CommitLegendPanel.java
src/com/gitblit/wicket/panels/LogPanel.java
src/com/gitblit/wicket/panels/TagsPanel.java
src/com/gitblit/wicket/resources/gitblit.css
tests/com/gitblit/tests/JGitUtilsTest.java
tests/com/gitblit/tests/MetricUtilsTest.java
tests/com/gitblit/tests/StringUtilsTest.java
tests/com/gitblit/tests/TicgitUtilsTest.java

diff --git a/src/com/gitblit/models/AnnotatedLine.java b/src/com/gitblit/models/AnnotatedLine.java
new file mode 100644 (file)
index 0000000..3d12476
--- /dev/null
@@ -0,0 +1,40 @@
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.models;\r
+\r
+import java.io.Serializable;\r
+import java.util.Date;\r
+\r
+import org.eclipse.jgit.revwalk.RevCommit;\r
+\r
+public class AnnotatedLine implements Serializable {\r
+\r
+       private static final long serialVersionUID = 1L;\r
+\r
+       public final String commitId;\r
+       public final String author;\r
+       public final Date when;\r
+       public final int lineNumber;\r
+       public final String data;\r
+\r
+       public AnnotatedLine(RevCommit commit, int lineNumber, String data) {\r
+               this.commitId = commit.getName();\r
+               this.author = commit.getAuthorIdent().getName();\r
+               this.when = commit.getAuthorIdent().getWhen();\r
+               this.lineNumber = lineNumber;\r
+               this.data = data;\r
+       }\r
+}
\ No newline at end of file
index 0083637c24379435a9a8bddd36a8e039420cf627..3b66d89f176c8fc5031de9b489a269a3b600abcf 100644 (file)
@@ -22,7 +22,7 @@ public class GitNote implements Serializable {
        private static final long serialVersionUID = 1L;\r
 \r
        public String content;\r
-       public RefModel notesRef;       \r
+       public RefModel notesRef;\r
 \r
        public GitNote(RefModel notesRef, String text) {\r
                this.notesRef = notesRef;\r
index 0b65c092fc7c73bb4951797f0e391a1699964ece..92c394c19dc24b80c883af99249a7319b102261e 100644 (file)
@@ -127,7 +127,7 @@ public class RefModel implements Serializable, Comparable<RefModel> {
        public int compareTo(RefModel o) {\r
                return getDate().compareTo(o.getDate());\r
        }\r
-       \r
+\r
        @Override\r
        public String toString() {\r
                return displayName;\r
index fab9f43b61ce15b5b5aeebcc01d3b961c971960a..0f569074684750bf76e75e07068cbb13a0ee51c8 100644 (file)
 package com.gitblit.utils;\r
 \r
 import java.io.ByteArrayOutputStream;\r
+import java.util.ArrayList;\r
 import java.util.List;\r
 \r
+import org.eclipse.jgit.api.BlameCommand;\r
+import org.eclipse.jgit.blame.BlameResult;\r
 import org.eclipse.jgit.diff.DiffEntry;\r
 import org.eclipse.jgit.diff.DiffFormatter;\r
+import org.eclipse.jgit.diff.RawText;\r
 import org.eclipse.jgit.diff.RawTextComparator;\r
 import org.eclipse.jgit.lib.Repository;\r
 import org.eclipse.jgit.revwalk.RevCommit;\r
@@ -30,6 +34,8 @@ import org.eclipse.jgit.treewalk.filter.TreeFilter;
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
+import com.gitblit.models.AnnotatedLine;\r
+\r
 public class DiffUtils {\r
 \r
        private static final Logger LOGGER = LoggerFactory.getLogger(DiffUtils.class);\r
@@ -172,4 +178,24 @@ public class DiffUtils {
                }\r
                return null;\r
        }\r
+\r
+       public static List<AnnotatedLine> blame(Repository r, String blobPath, String objectId) {\r
+               List<AnnotatedLine> lines = new ArrayList<AnnotatedLine>();\r
+               try {\r
+                       BlameCommand blameCommand = new BlameCommand(r);\r
+                       blameCommand.setFilePath(blobPath);\r
+                       blameCommand.setStartCommit(r.resolve(objectId));\r
+                       BlameResult blameResult = blameCommand.call();\r
+                       RawText rawText = blameResult.getResultContents();\r
+                       int length = rawText.size();\r
+                       for (int i = 0; i < length; i++) {\r
+                               RevCommit commit = blameResult.getSourceCommit(i);\r
+                               AnnotatedLine line = new AnnotatedLine(commit, i + 1, rawText.getString(i));\r
+                               lines.add(line);\r
+                       }\r
+               } catch (Throwable t) {\r
+                       LOGGER.error("failed to generate blame!", t);\r
+               }\r
+               return lines;\r
+       }\r
 }\r
index f6d7108b72feab7e1a1390020d95554b481eb0b9..e8bb3bf2742645f52416ad87facc7ca321920bca 100644 (file)
@@ -96,7 +96,8 @@ public class JGitUtils {
                return r.toString().trim();\r
        }\r
 \r
-       public static FetchResult cloneRepository(File repositoriesFolder, String name, String fromUrl) throws Exception {\r
+       public static FetchResult cloneRepository(File repositoriesFolder, String name, String fromUrl)\r
+                       throws Exception {\r
                FetchResult result = null;\r
                if (!name.toLowerCase().endsWith(Constants.DOT_GIT_EXT)) {\r
                        name += Constants.DOT_GIT_EXT;\r
index 492b024349066f77390dc123b4a5791608d537c2..85ef89f1127b5c4c44fcf15a95a670a5f59cc48b 100644 (file)
@@ -39,7 +39,8 @@ public class MetricUtils {
 \r
        private static final Logger LOGGER = LoggerFactory.getLogger(MetricUtils.class);\r
 \r
-       public static List<Metric> getDateMetrics(Repository r, String objectId, boolean includeTotal, String format) {\r
+       public static List<Metric> getDateMetrics(Repository r, String objectId, boolean includeTotal,\r
+                       String format) {\r
                Metric total = new Metric("TOTAL");\r
                final Map<String, Metric> metricMap = new HashMap<String, Metric>();\r
                if (StringUtils.isEmpty(objectId)) {\r
index 2a10a59a6ccc42ef6e002d8e32eff2266f3b076e..a881b58c4e79d2c55d7bde22b7cae88d90636283 100644 (file)
@@ -134,8 +134,8 @@ public class StringUtils {
                }\r
                return "";\r
        }\r
-       \r
-       public static String getRelativePath(String basePath, String fullPath) {                \r
+\r
+       public static String getRelativePath(String basePath, String fullPath) {\r
                String relativePath = fullPath.substring(basePath.length()).replace('\\', '/');\r
                if (relativePath.charAt(0) == '/') {\r
                        relativePath = relativePath.substring(1);\r
index 44f51a5535040f03d382babc4fffaea6d00058b3..dcb60ab0b9fcd1d10ee2f943165ce22586827fa7 100644 (file)
@@ -30,14 +30,14 @@ public class TimeUtils {
        public static final long ONEYEAR = ONEDAY * 365L;\r
 \r
        public static boolean isToday(Date date) {\r
-               return (System.currentTimeMillis() - date.getTime()) < ONEDAY; \r
+               return (System.currentTimeMillis() - date.getTime()) < ONEDAY;\r
        }\r
 \r
        public static boolean isYesterday(Date date) {\r
                Calendar cal = Calendar.getInstance();\r
                cal.setTime(date);\r
                cal.add(Calendar.DATE, 1);\r
-               return (System.currentTimeMillis() - cal.getTimeInMillis()) < ONEDAY; \r
+               return (System.currentTimeMillis() - cal.getTimeInMillis()) < ONEDAY;\r
        }\r
 \r
        public static String duration(int days) {\r
index daf10845bca4f5848539a3ce8d3be329bbe4c18a..472a11dc5c194d987fac4612a24dc7108076ae05 100644 (file)
@@ -87,7 +87,7 @@ public class GitBlitWebApp extends WebApplication {
                mount("/search", SearchPage.class);\r
                mount("/metrics", MetricsPage.class, "r");\r
                mount("/blame", BlamePage.class, "r", "h", "f");\r
-               \r
+\r
                // setup ticket urls\r
                mount("/tickets", TicketsPage.class, "r");\r
                mount("/ticket", TicketPage.class, "r", "h", "f");\r
index aef68eee4c851e2e2326cc09aa7b66dfb693ccd0..1d2a60fe879455cc485e1c4853989ea2dc5470fc 100644 (file)
@@ -299,7 +299,7 @@ public class WicketUtils {
                WicketUtils.setHtmlTooltip(label, title);\r
                return label;\r
        }\r
-       \r
+\r
        public static IChartData getChartData(Collection<Metric> metrics) {\r
                final double[] commits = new double[metrics.size()];\r
                final double[] tags = new double[metrics.size()];\r
@@ -334,7 +334,7 @@ public class WicketUtils {
                }\r
                return max;\r
        }\r
-       \r
+\r
        public static IChartData getScatterData(Collection<Metric> metrics) {\r
                final double[] y = new double[metrics.size()];\r
                final double[] x = new double[metrics.size()];\r
index 27ed734525fd2cb42eab9a1f3c0c4cfa5fa251c1..2e20c189a8814e779d8fca819b55fc193d224bfb 100644 (file)
@@ -19,7 +19,7 @@
        <div wicket:id="breadcrumbs">[breadcrumbs]</div>\r
                \r
        <!--  blame content -->\r
-       <table>\r
+       <table class="annotated" style="border-top: 0px; margin-bottom:5px;">\r
                <tbody>\r
                        <tr>\r
                                <th>Commit</th>\r
@@ -27,9 +27,9 @@
                                <th>Data</th>\r
                        </tr>\r
                        <tr wicket:id="annotation">\r
-                               <td><span wicket:id="commit"></span></td>\r
-                               <td><span wicket:id="line"></span></td>\r
-                               <td><span wicket:id="data"></span></td>\r
+                               <td><span class="sha1" wicket:id="commit"></span></td>\r
+                               <td><span class="sha1" wicket:id="line"></span></td>\r
+                               <td><span class="sha1" wicket:id="data"></span></td>\r
                        </tr>\r
                </tbody>\r
        </table>\r
index dc6aa1f998248bd6208a70925a53c6e7d7aa4e89..5462b8827525b820cc2880646ce7ab15ac90fe40 100644 (file)
@@ -15,8 +15,9 @@
  */\r
 package com.gitblit.wicket.pages;\r
 \r
-import java.io.Serializable;\r
-import java.util.Arrays;\r
+import java.text.DateFormat;\r
+import java.text.MessageFormat;\r
+import java.text.SimpleDateFormat;\r
 import java.util.List;\r
 \r
 import org.apache.wicket.PageParameters;\r
@@ -28,6 +29,11 @@ import org.apache.wicket.markup.repeater.data.ListDataProvider;
 import org.eclipse.jgit.lib.Constants;\r
 import org.eclipse.jgit.revwalk.RevCommit;\r
 \r
+import com.gitblit.GitBlit;\r
+import com.gitblit.Keys;\r
+import com.gitblit.models.AnnotatedLine;\r
+import com.gitblit.utils.DiffUtils;\r
+import com.gitblit.utils.StringUtils;\r
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.panels.CommitHeaderPanel;\r
 import com.gitblit.wicket.panels.LinkPanel;\r
@@ -43,8 +49,7 @@ public class BlamePage extends RepositoryPage {
                RevCommit commit = getCommit();\r
 \r
                add(new BookmarkablePageLink<Void>("blobLink", BlobPage.class,\r
-                               WicketUtils.newPathParameter(repositoryName, objectId,\r
-                                                       blobPath)));\r
+                               WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));\r
                add(new BookmarkablePageLink<Void>("commitLink", CommitPage.class,\r
                                WicketUtils.newObjectParameter(repositoryName, objectId)));\r
                add(new BookmarkablePageLink<Void>("commitDiffLink", CommitDiffPage.class,\r
@@ -60,38 +65,65 @@ public class BlamePage extends RepositoryPage {
 \r
                add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, objectId));\r
 \r
-               List<BlameLine> blame = Arrays.asList(new BlameLine("HEAD", "1", "Under Construction"));\r
-               ListDataProvider<BlameLine> blameDp = new ListDataProvider<BlameLine>(blame);\r
-               DataView<BlameLine> blameView = new DataView<BlameLine>("annotation", blameDp) {\r
+               String format = GitBlit.getString(Keys.web.datetimestampLongFormat,\r
+                               "EEEE, MMMM d, yyyy h:mm a z");\r
+               final DateFormat df = new SimpleDateFormat(format);\r
+               df.setTimeZone(getTimeZone());\r
+               List<AnnotatedLine> lines = DiffUtils.blame(getRepository(), blobPath, objectId);\r
+               ListDataProvider<AnnotatedLine> blameDp = new ListDataProvider<AnnotatedLine>(lines);\r
+               DataView<AnnotatedLine> blameView = new DataView<AnnotatedLine>("annotation", blameDp) {\r
                        private static final long serialVersionUID = 1L;\r
+                       private int count;\r
+                       private String lastCommitId = "";\r
+                       private boolean showInitials = true;\r
 \r
-                       public void populateItem(final Item<BlameLine> item) {\r
-                               BlameLine entry = item.getModelObject();\r
-                               item.add(new LinkPanel("commit", "list", entry.objectId, CommitPage.class,\r
-                                               newCommitParameter(entry.objectId)));\r
-                               item.add(new Label("line", entry.line));\r
-                               item.add(new Label("data", entry.data));\r
+                       public void populateItem(final Item<AnnotatedLine> item) {\r
+                               AnnotatedLine entry = item.getModelObject();\r
+                               item.add(new Label("line", "" + entry.lineNumber));\r
+                               item.add(new Label("data", StringUtils.escapeForHtml(entry.data, true))\r
+                                               .setEscapeModelStrings(false));\r
+                               if (!lastCommitId.equals(entry.commitId)) {\r
+                                       lastCommitId = entry.commitId;\r
+                                       count++;\r
+                                       // show the link for first line\r
+                                       LinkPanel commitLink = new LinkPanel("commit", null,\r
+                                                       getShortObjectId(entry.commitId), CommitPage.class,\r
+                                                       newCommitParameter(entry.commitId));\r
+                                       WicketUtils.setHtmlTooltip(commitLink,\r
+                                                       MessageFormat.format("{0}, {1}", entry.author, df.format(entry.when)));\r
+                                       item.add(commitLink);\r
+                                       showInitials = true;\r
+                               } else {\r
+                                       if (showInitials) {\r
+                                               showInitials = false;\r
+                                               // show author initials\r
+                                               item.add(new Label("commit", getInitials(entry.author)));\r
+                                       } else {\r
+                                               // hide the commit link until the next block\r
+                                               item.add(new Label("commit").setVisible(false));\r
+                                       }\r
+                               }\r
+                               if (count % 2 == 0) {\r
+                                       WicketUtils.setCssClass(item, "even");\r
+                               } else {\r
+                                       WicketUtils.setCssClass(item, "odd");\r
+                               }\r
                        }\r
                };\r
                add(blameView);\r
        }\r
 \r
+       private String getInitials(String author) {\r
+               StringBuilder sb = new StringBuilder();\r
+               String[] chunks = author.split(" ");\r
+               for (String chunk : chunks) {\r
+                       sb.append(chunk.charAt(0));\r
+               }\r
+               return sb.toString().toUpperCase();\r
+       }\r
+\r
        @Override\r
        protected String getPageName() {\r
                return getString("gb.blame");\r
        }\r
-       \r
-       private class BlameLine implements Serializable {\r
-               \r
-               private static final long serialVersionUID = 1L;\r
-               \r
-               final String objectId;\r
-               final String line;\r
-               final String data;\r
-               BlameLine(String objectId, String line, String data) {\r
-                       this.objectId = objectId;\r
-                       this.line = line;\r
-                       this.data = data;\r
-               }\r
-       }\r
 }\r
index 47c8ca8266427e2419ed2c7495eb37df9b24455d..1c438370a6c7b7a0c2907aa95cc79a34b58a04db 100644 (file)
@@ -46,7 +46,8 @@ public class BlobPage extends RepositoryPage {
                        // blob by objectid\r
 \r
                        add(new BookmarkablePageLink<Void>("blameLink", BlamePage.class,\r
-                                       WicketUtils.newPathParameter(repositoryName, objectId, blobPath)).setEnabled(false));\r
+                                       WicketUtils.newPathParameter(repositoryName, objectId, blobPath))\r
+                                       .setEnabled(false));\r
                        add(new BookmarkablePageLink<Void>("historyLink", HistoryPage.class).setEnabled(false));\r
                        add(new BookmarkablePageLink<Void>("rawLink", RawPage.class,\r
                                        WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));\r
index 3abcf131a26543733823e4342f087d9add45865d..ecfcbacde1f79b9fd5b0937bf5585338f5dee2e3 100644 (file)
@@ -101,7 +101,8 @@ public class CommitDiffPage extends RepositoryPage {
                                item.add(new BookmarkablePageLink<Void>("blame", BlamePage.class,\r
                                                newPathParameter(entry.path)));\r
                                item.add(new BookmarkablePageLink<Void>("history", HistoryPage.class,\r
-                                               newPathParameter(entry.path)).setEnabled(!entry.changeType.equals(ChangeType.ADD)));\r
+                                               newPathParameter(entry.path)).setEnabled(!entry.changeType\r
+                                               .equals(ChangeType.ADD)));\r
 \r
                                WicketUtils.setAlternatingBackground(item, counter);\r
                                counter++;\r
index d9ff1b78e6c2f5c16edf94d8fe1013c53990a196..02956001a5266ed846183aab2e707cedd08fdd90 100644 (file)
@@ -65,8 +65,8 @@ public class CommitPage extends RepositoryPage {
                        add(new Label("parentLink", "none"));\r
                        add(new Label("commitdiffLink", getString("gb.commitdiff")));\r
                } else {\r
-                       add(new LinkPanel("parentLink", null, parents.get(0).substring(0, 8), CommitPage.class,\r
-                                       newCommitParameter(parents.get(0))));\r
+                       add(new LinkPanel("parentLink", null, getShortObjectId(parents.get(0)),\r
+                                       CommitPage.class, newCommitParameter(parents.get(0))));\r
                        add(new LinkPanel("commitdiffLink", null, new StringResourceModel("gb.commitdiff",\r
                                        this, null), CommitDiffPage.class, WicketUtils.newObjectParameter(\r
                                        repositoryName, objectId)));\r
index e5496a1a891cc4c5627b504ba11b0b070d4c4872..52ed548c8a061925bf0e555b23a459e8977cc8b9 100644 (file)
@@ -107,11 +107,11 @@ public class EditRepositoryPage extends BasePage {
                                        repositoryModel.name = repositoryModel.name.replace("//", "/");\r
 \r
                                        // prohibit folder paths\r
-                                       if (repositoryModel.name.startsWith("/")) {                                             \r
+                                       if (repositoryModel.name.startsWith("/")) {\r
                                                error("Leading root folder references (/) are prohibited.");\r
                                                return;\r
                                        }\r
-                                       if (repositoryModel.name.startsWith("../")) {                                           \r
+                                       if (repositoryModel.name.startsWith("../")) {\r
                                                error("Relative folder references (../) are prohibited.");\r
                                                return;\r
                                        }\r
@@ -135,7 +135,7 @@ public class EditRepositoryPage extends BasePage {
                                                        }\r
                                                }\r
                                        }\r
-                                       \r
+\r
                                        // confirm access restriction selection\r
                                        if (repositoryModel.accessRestriction == null) {\r
                                                error("Please select access restriction!");\r
index 9dd10d1b51a23850bb5ce90f9380502fcb1c206f..4d0cd4cb9ffdfc79c346f62ba6bfaac29d67c11f 100644 (file)
@@ -46,18 +46,18 @@ import com.gitblit.wicket.WicketUtils;
 public class MetricsPage extends RepositoryPage {\r
 \r
        public MetricsPage(PageParameters params) {\r
-               super(params);                          \r
+               super(params);\r
                Repository r = getRepository();\r
                add(new Label("branchTitle", objectId));\r
                Metric metricsTotal = null;\r
                List<Metric> metrics = MetricUtils.getDateMetrics(r, objectId, true, null);\r
                metricsTotal = metrics.remove(0);\r
                if (metricsTotal == null) {\r
-                       add(new Label("branchStats", ""));                      \r
+                       add(new Label("branchStats", ""));\r
                } else {\r
-                       add(new Label("branchStats", MessageFormat.format(\r
-                                       "{0} commits and {1} tags in {2}", metricsTotal.count, metricsTotal.tag,\r
-                                       TimeUtils.duration(metricsTotal.duration))));\r
+                       add(new Label("branchStats",\r
+                                       MessageFormat.format("{0} commits and {1} tags in {2}", metricsTotal.count,\r
+                                                       metricsTotal.tag, TimeUtils.duration(metricsTotal.duration))));\r
                }\r
                insertLinePlot("commitsChart", metrics);\r
                insertBarPlot("dayOfWeekChart", getDayOfWeekMetrics(r, objectId));\r
index 3ceb9f5fb216e2fc6c908b9111a91cae55e4b435..e2120f7762c220470ce1c7e90d27f99cf6ff00db 100644 (file)
@@ -218,6 +218,10 @@ public abstract class RepositoryPage extends BasePage {
                return commit;\r
        }\r
 \r
+       protected String getShortObjectId(String objectId) {\r
+               return objectId.substring(0, 8);\r
+       }\r
+\r
        protected void addRefs(Repository r, RevCommit c) {\r
                add(new RefsPanel("refsPanel", repositoryName, c, JGitUtils.getAllRefs(r)));\r
        }\r
index 37b0bcff71037d4947b39042cf87057a1f824c39..e85901ab6aa1ceb8cfa61f8e0e676eee9463fe46 100644 (file)
@@ -89,13 +89,14 @@ public class SummaryPage extends RepositoryPage {
                add(WicketUtils.createTimestampLabel("repositoryLastChange", JGitUtils.getLastChange(r),\r
                                getTimeZone()));\r
                if (metricsTotal == null) {\r
-                       add(new Label("branchStats", ""));                      \r
+                       add(new Label("branchStats", ""));\r
                } else {\r
-                       add(new Label("branchStats", MessageFormat.format(\r
-                                       "{0} commits and {1} tags in {2}", metricsTotal.count, metricsTotal.tag,\r
-                                       TimeUtils.duration(metricsTotal.duration))));\r
+                       add(new Label("branchStats",\r
+                                       MessageFormat.format("{0} commits and {1} tags in {2}", metricsTotal.count,\r
+                                                       metricsTotal.tag, TimeUtils.duration(metricsTotal.duration))));\r
                }\r
-               add(new BookmarkablePageLink<Void>("metrics", MetricsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
+               add(new BookmarkablePageLink<Void>("metrics", MetricsPage.class,\r
+                               WicketUtils.newRepositoryParameter(repositoryName)));\r
 \r
                List<String> repositoryUrls = new ArrayList<String>();\r
 \r
@@ -203,7 +204,7 @@ public class SummaryPage extends RepositoryPage {
                                        metrics.get(metrics.size() / 2).name, metrics.get(metrics.size() - 1).name });\r
                        provider.addAxis(dateAxis);\r
 \r
-                       ChartAxis commitAxis = new ChartAxis(ChartAxisType.LEFT);                       \r
+                       ChartAxis commitAxis = new ChartAxis(ChartAxisType.LEFT);\r
                        commitAxis.setLabels(new String[] { "",\r
                                        String.valueOf((int) WicketUtils.maxValue(metrics)) });\r
                        provider.addAxis(commitAxis);\r
index 7d0ad0f0bc44fc41be1655d4a8de12cdc714ef49..1f6ae56fe1ea83ce3d30b3d3d975f14d07ff9fe8 100644 (file)
@@ -32,7 +32,7 @@ public class CommitHeaderPanel extends BasePanel {
                add(new Label("author"));\r
                add(new Label("date"));\r
        }\r
-       \r
+\r
        public CommitHeaderPanel(String id, String repositoryName, RevCommit c) {\r
                super(id);\r
                add(new LinkPanel("shortmessage", "title", c.getShortMessage(), CommitPage.class,\r
index d875233a70a805582a1b300c2f6857b81520c29c..1e906ef70a98ad5d827e26de32d3ceccd30462ca 100644 (file)
@@ -74,7 +74,7 @@ public class CommitLegendPanel extends Panel {
                };\r
                add(legendsView);\r
        }\r
-       \r
+\r
        protected Map<ChangeType, AtomicInteger> getChangedPathsStats(List<PathChangeModel> paths) {\r
                Map<ChangeType, AtomicInteger> stats = new HashMap<ChangeType, AtomicInteger>();\r
                for (PathChangeModel path : paths) {\r
index 873d7d9b6a0ed88eac6a4927b4e2f75cbe6dc47f..66fddd2cbbf10f564e80f01866817962fb686237 100644 (file)
@@ -127,7 +127,8 @@ public class LogPanel extends BasePanel {
                                item.add(new BookmarkablePageLink<Void>("view", CommitPage.class, WicketUtils\r
                                                .newObjectParameter(repositoryName, entry.getName())));\r
                                item.add(new BookmarkablePageLink<Void>("diff", CommitDiffPage.class, WicketUtils\r
-                                               .newObjectParameter(repositoryName, entry.getName())).setEnabled(entry.getParentCount() > 0));\r
+                                               .newObjectParameter(repositoryName, entry.getName())).setEnabled(entry\r
+                                               .getParentCount() > 0));\r
                                item.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils\r
                                                .newObjectParameter(repositoryName, entry.getName())));\r
 \r
index 4504c5116ea12c2ee76587810a85b7c7e7e35ce3..95bc8575b994956bafd3ae84b12726ae9ad2849a 100644 (file)
@@ -44,7 +44,7 @@ import com.gitblit.wicket.pages.TreePage;
 public class TagsPanel extends BasePanel {\r
 \r
        private static final long serialVersionUID = 1L;\r
-       \r
+\r
        private final boolean hasTags;\r
 \r
        public TagsPanel(String wicketId, final String repositoryName, Repository r, final int maxCount) {\r
@@ -164,10 +164,10 @@ public class TagsPanel extends BasePanel {
                        add(new LinkPanel("allTags", "link", new StringResourceModel("gb.allTags", this, null),\r
                                        TagsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
                }\r
-               \r
+\r
                hasTags = tags.size() > 0;\r
        }\r
-       \r
+\r
        public TagsPanel hideIfEmpty() {\r
                setVisible(hasTags);\r
                return this;\r
index 7c896dffe8fbc8379bd86d61453cf618e4025f7a..4309458809bf48925202ea9b9d4666f5b0349349 100644 (file)
@@ -633,6 +633,19 @@ table.gitnotes td.message {
        border-left: 1px solid #ccc;\r
 }\r
 \r
+table.annotated {\r
+       width: 100%;\r
+       border: 1px solid #bbb;\r
+}\r
+\r
+table.annotated tr.even {\r
+       background-color: white;\r
+}\r
+\r
+table.annotated tr.odd {\r
+       background-color: #fdfbdf;\r
+}\r
+\r
 tr th a { padding-right: 15px; background-position: right; background-repeat:no-repeat; }\r
 tr th.wicket_orderDown a {background-image: url(arrow_down.png); }\r
 tr th.wicket_orderUp a { background-image: url(arrow_up.png); }\r
index 277166cfe78fd937d45203f51834420534b2c842..1b57585646e1cac06ddb57aa5206f16c06c5bbc8 100644 (file)
@@ -96,10 +96,11 @@ public class JGitUtilsTest extends TestCase {
 \r
        public void testCreateRepository() throws Exception {\r
                String[] repositories = { "NewTestRepository.git", "NewTestRepository" };\r
-               for (String repositoryName : repositories) {                    \r
+               for (String repositoryName : repositories) {\r
                        Repository repository = JGitUtils.createRepository(GitBlitSuite.REPOSITORIES,\r
                                        repositoryName);\r
-                       File folder = FileKey.resolve(new File(GitBlitSuite.REPOSITORIES, repositoryName), FS.DETECTED);\r
+                       File folder = FileKey.resolve(new File(GitBlitSuite.REPOSITORIES, repositoryName),\r
+                                       FS.DETECTED);\r
                        assertTrue(repository != null);\r
                        assertFalse(JGitUtils.hasCommits(repository));\r
                        assertTrue(JGitUtils.getFirstCommit(repository, null) == null);\r
@@ -121,10 +122,11 @@ public class JGitUtilsTest extends TestCase {
                        List<RefModel> list = entry.getValue();\r
                        for (RefModel ref : list) {\r
                                if (ref.displayName.equals("refs/tags/spearce-gpg-pub")) {\r
-                                       assertTrue(ref.getObjectId().getName().equals("8bbde7aacf771a9afb6992434f1ae413e010c6d8"));\r
+                                       assertTrue(ref.getObjectId().getName()\r
+                                                       .equals("8bbde7aacf771a9afb6992434f1ae413e010c6d8"));\r
                                        assertTrue(ref.getAuthorIdent().getEmailAddress().equals("spearce@spearce.org"));\r
                                        assertTrue(ref.getShortMessage().startsWith("GPG key"));\r
-                                       assertTrue(ref.getFullMessage().startsWith("GPG key"));                                 \r
+                                       assertTrue(ref.getFullMessage().startsWith("GPG key"));\r
                                        assertTrue(ref.getReferencedObjectType() == Constants.OBJ_BLOB);\r
                                } else if (ref.displayName.equals("refs/tags/v0.12.1")) {\r
                                        assertTrue(ref.isAnnotatedTag());\r
@@ -168,13 +170,14 @@ public class JGitUtilsTest extends TestCase {
                                        + model.getName().hashCode());\r
                }\r
                repository.close();\r
-               \r
+\r
                repository = GitBlitSuite.getBluezGnomeRepository();\r
                for (RefModel model : JGitUtils.getTags(repository, true, -1)) {\r
                        if (model.getObjectId().getName().equals("728643ec0c438c77e182898c2f2967dbfdc231c8")) {\r
                                assertFalse(model.isAnnotatedTag());\r
                                assertTrue(model.getAuthorIdent().getEmailAddress().equals("marcel@holtmann.org"));\r
-                               assertTrue(model.getFullMessage().equals("Update changelog and bump version number\n"));\r
+                               assertTrue(model.getFullMessage().equals(\r
+                                               "Update changelog and bump version number\n"));\r
                        }\r
                }\r
                repository.close();\r
index db994b80cd9f639c524d034f2d198cdcb9ec73a6..c9d007df523f0325596ed4b17229b75f5b0e082f 100644 (file)
@@ -32,7 +32,7 @@ public class MetricUtilsTest extends TestCase {
                repository.close();\r
                assertTrue("No date metrics found!", metrics.size() > 0);\r
        }\r
-       \r
+\r
        public void testAuthorMetrics() throws Exception {\r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
                List<Metric> byEmail = MetricUtils.getAuthorMetrics(repository, null, true);\r
index 49938ae4bf9eea951e2012a5d3f930df1dd9396e..df51a4bbafe3b079a25a9b824a96d5428c557e2e 100644 (file)
@@ -38,10 +38,10 @@ public class StringUtilsTest extends TestCase {
 \r
        public void testEscapeForHtml() throws Exception {\r
                String input = "& < > \" \t";\r
-               String output_nochange = "&amp; &lt; &gt; &quot; \t";\r
-               String output_change = "&amp;&nbsp;&lt;&nbsp;&gt;&nbsp;&quot;&nbsp; &nbsp; &nbsp;";\r
-               assertTrue(StringUtils.escapeForHtml(input, false).equals(output_nochange));\r
-               assertTrue(StringUtils.escapeForHtml(input, true).equals(output_change));\r
+               String outputNoChange = "&amp; &lt; &gt; &quot; \t";\r
+               String outputChange = "&amp;&nbsp;&lt;&nbsp;&gt;&nbsp;&quot;&nbsp; &nbsp; &nbsp;";\r
+               assertTrue(StringUtils.escapeForHtml(input, false).equals(outputNoChange));\r
+               assertTrue(StringUtils.escapeForHtml(input, true).equals(outputChange));\r
        }\r
 \r
        public void testFlattenStrings() throws Exception {\r
index 792c4269b5a99859bae7ccfc29d8d231117345a9..9f5a488bbe8d50cc50cea46cbdc5dae3c6a74e71 100644 (file)
@@ -33,7 +33,7 @@ public class TicgitUtilsTest extends TestCase {
                RefModel branch = TicgitUtils.getTicketsBranch(repository);\r
                repository.close();\r
                assertTrue("Ticgit branch does not exist!", branch != null);\r
-               \r
+\r
                repository = GitBlitSuite.getHelloworldRepository();\r
                branch = TicgitUtils.getTicketsBranch(repository);\r
                repository.close();\r
@@ -60,7 +60,7 @@ public class TicgitUtilsTest extends TestCase {
                                assertTrue(commentA.hashCode() == commentA.text.hashCode());\r
                        }\r
                }\r
-               \r
+\r
                repository = GitBlitSuite.getHelloworldRepository();\r
                List<TicketModel> ticketsC = TicgitUtils.getTickets(repository);\r
                repository.close();\r