]> source.dussan.org Git - gitblit.git/commitdiff
Improved metrics page and added metrics links to branches panel.
authorJames Moger <james.moger@gitblit.com>
Wed, 8 Jun 2011 00:55:19 +0000 (20:55 -0400)
committerJames Moger <james.moger@gitblit.com>
Wed, 8 Jun 2011 00:55:19 +0000 (20:55 -0400)
16 files changed:
docs/00_index.mkd
src/com/gitblit/models/RefModel.java
src/com/gitblit/utils/MetricUtils.java
src/com/gitblit/wicket/GitBlitWebApp.properties
src/com/gitblit/wicket/pages/MetricsPage.html
src/com/gitblit/wicket/pages/MetricsPage.java
src/com/gitblit/wicket/pages/RepositoryPage.html
src/com/gitblit/wicket/pages/RepositoryPage.java
src/com/gitblit/wicket/pages/SummaryPage.html
src/com/gitblit/wicket/pages/SummaryPage.java
src/com/gitblit/wicket/panels/BranchesPanel.html
src/com/gitblit/wicket/panels/BranchesPanel.java
src/com/gitblit/wicket/panels/RefsPanel.java
src/com/gitblit/wicket/panels/TagsPanel.java
src/com/gitblit/wicket/resources/gitblit.css
tests/com/gitblit/tests/MetricUtilsTest.java

index 8c8f9322821a6fa17466b179616954d3dd62cdd0..d13316367898718705bb2df9676c882cc9850f9a 100644 (file)
@@ -56,7 +56,6 @@ sources @ [Github][gitbltsrc]
 ### Todo List\r
 - Code documentation\r
 - Unit testing\r
-- Branch selector on Metrics\r
 - Blame\r
 - Clone remote repository\r
 \r
index 39bf19c94faf74cd8cb82529acd381755e69609b..0b65c092fc7c73bb4951797f0e391a1699964ece 100644 (file)
@@ -127,4 +127,9 @@ public class RefModel implements Serializable, Comparable<RefModel> {
        public int compareTo(RefModel o) {\r
                return getDate().compareTo(o.getDate());\r
        }\r
+       \r
+       @Override\r
+       public String toString() {\r
+               return displayName;\r
+       }\r
 }
\ No newline at end of file
index d8286e290291b1b756660c460eb30e3f7567c189..492b024349066f77390dc123b4a5791608d537c2 100644 (file)
@@ -39,10 +39,12 @@ public class MetricUtils {
 \r
        private static final Logger LOGGER = LoggerFactory.getLogger(MetricUtils.class);\r
 \r
-       public static List<Metric> getDateMetrics(Repository r, boolean includeTotal, String format) {\r
+       public static List<Metric> getDateMetrics(Repository r, String objectId, boolean includeTotal, String format) {\r
                Metric total = new Metric("TOTAL");\r
                final Map<String, Metric> metricMap = new HashMap<String, Metric>();\r
-\r
+               if (StringUtils.isEmpty(objectId)) {\r
+                       objectId = Constants.HEAD;\r
+               }\r
                if (JGitUtils.hasCommits(r)) {\r
                        final List<RefModel> tags = JGitUtils.getTags(r, true, -1);\r
                        final Map<ObjectId, RefModel> tagMap = new HashMap<ObjectId, RefModel>();\r
@@ -51,7 +53,7 @@ public class MetricUtils {
                        }\r
                        try {\r
                                RevWalk walk = new RevWalk(r);\r
-                               ObjectId object = r.resolve(Constants.HEAD);\r
+                               ObjectId object = r.resolve(objectId);\r
                                RevCommit lastCommit = walk.parseCommit(object);\r
                                walk.markStart(lastCommit);\r
 \r
@@ -62,12 +64,9 @@ public class MetricUtils {
                                        int diffDays = (lastCommit.getCommitTime() - firstCommit.getCommitTime())\r
                                                        / (60 * 60 * 24);\r
                                        total.duration = diffDays;\r
-                                       if (diffDays <= 90) {\r
+                                       if (diffDays <= 365) {\r
                                                // Days\r
                                                df = new SimpleDateFormat("yyyy-MM-dd");\r
-                                       } else if (diffDays > 90 && diffDays < 365) {\r
-                                               // Weeks\r
-                                               df = new SimpleDateFormat("yyyy-MM (w)");\r
                                        } else {\r
                                                // Months\r
                                                df = new SimpleDateFormat("yyyy-MM");\r
@@ -108,13 +107,15 @@ public class MetricUtils {
                return metrics;\r
        }\r
 \r
-       public static List<Metric> getAuthorMetrics(Repository r, boolean byEmail) {\r
+       public static List<Metric> getAuthorMetrics(Repository r, String objectId, boolean byEmail) {\r
                final Map<String, Metric> metricMap = new HashMap<String, Metric>();\r
-\r
+               if (StringUtils.isEmpty(objectId)) {\r
+                       objectId = Constants.HEAD;\r
+               }\r
                if (JGitUtils.hasCommits(r)) {\r
                        try {\r
                                RevWalk walk = new RevWalk(r);\r
-                               ObjectId object = r.resolve(Constants.HEAD);\r
+                               ObjectId object = r.resolve(objectId);\r
                                RevCommit lastCommit = walk.parseCommit(object);\r
                                walk.markStart(lastCommit);\r
 \r
index f64f1e56cc60e49ddfb2ff40fdf8cebd0bab174a..d6102dbf2a9f0fd24fa4b3915e08b14c3e92b5a0 100644 (file)
@@ -55,6 +55,7 @@ gb.modification = modification
 gb.deletion = deletion\r
 gb.rename = rename\r
 gb.metrics = metrics\r
+gb.stats = stats\r
 gb.markdown = markdown\r
 gb.changedFiles = changed files \r
 gb.filesAdded = {0} files added\r
@@ -94,4 +95,7 @@ gb.showReadme = show readme
 gb.showReadmeDescription = show a \"readme\" markdown file on the summary page\r
 gb.nameDescription = use '/' to group repositories.  e.g. libraries/mycoollib.git\r
 gb.ownerDescription = the owner may edit repository settings\r
-gb.blob = blob
\ No newline at end of file
+gb.blob = blob\r
+gb.commitActivityTrend = commit activity trend\r
+gb.commitActivityDOW = commit activity by day of week\r
+gb.commitActivityAuthors = primary authors by commit activity
\ No newline at end of file
index d6f23e0172b799e0360fa08e6024df9671bdaa5c..734b9fada46772b5608a8b723a9bdab3ec03cca4 100644 (file)
@@ -6,18 +6,30 @@
       \r
 <body>\r
 <wicket:extend>\r
-               <h2>Commit Activity</h2>\r
+       <div style="padding-top:10px;">\r
+               <!-- branch name -->\r
+               <div><span class="metricsTitle" wicket:id="branchTitle"></span></div>\r
+       \r
+               <!-- placeholder for more info -->\r
+               <div style="float:right;width:200px;text-align: left;">\r
+               </div>\r
+\r
+               <!-- branch stats -->\r
+               <h2><wicket:message key="gb.stats"></wicket:message></h2>\r
+               <span wicket:id="branchStats"></span>\r
+               \r
+               <!-- commit activity trend -->\r
+               <h2><wicket:message key="gb.commitActivityTrend"></wicket:message></h2>\r
                <div><img wicket:id="commitsChart" /></div>\r
                \r
-               <h2>Commit Activity by Day of Week</h2>\r
+               <!-- commit activity by day of week -->\r
+               <h2><wicket:message key="gb.commitActivityDOW"></wicket:message></h2>\r
                <div><img wicket:id="dayOfWeekChart" /></div>\r
                \r
-               <h2>Commit Activity by Time of Day</h2>\r
-               <div><img wicket:id="timeOfDayChart" /></div>\r
-\r
-               <h2>Most Prolific Authors</h2>\r
+               <!-- commit activity by primary authors -->\r
+               <h2><wicket:message key="gb.commitActivityAuthors"></wicket:message></h2>\r
                <div><img wicket:id="authorsChart" /></div>\r
-\r
+       </div>\r
 </wicket:extend>\r
 </body>\r
 </html>
\ No newline at end of file
index c6231e9dc773682402549b7ab7f31771013547a1..9dd10d1b51a23850bb5ce90f9380502fcb1c206f 100644 (file)
@@ -17,16 +17,16 @@ package com.gitblit.wicket.pages;
 \r
 import java.awt.Color;\r
 import java.awt.Dimension;\r
-import java.text.ParseException;\r
+import java.text.MessageFormat;\r
 import java.text.SimpleDateFormat;\r
 import java.util.ArrayList;\r
 import java.util.Calendar;\r
 import java.util.Collections;\r
 import java.util.Comparator;\r
-import java.util.Date;\r
 import java.util.List;\r
 \r
 import org.apache.wicket.PageParameters;\r
+import org.apache.wicket.markup.html.basic.Label;\r
 import org.eclipse.jgit.lib.Repository;\r
 import org.wicketstuff.googlecharts.Chart;\r
 import org.wicketstuff.googlecharts.ChartAxis;\r
@@ -40,17 +40,28 @@ import org.wicketstuff.googlecharts.ShapeMarker;
 \r
 import com.gitblit.models.Metric;\r
 import com.gitblit.utils.MetricUtils;\r
+import com.gitblit.utils.TimeUtils;\r
 import com.gitblit.wicket.WicketUtils;\r
 \r
 public class MetricsPage extends RepositoryPage {\r
 \r
        public MetricsPage(PageParameters params) {\r
-               super(params);\r
+               super(params);                          \r
                Repository r = getRepository();\r
-               insertLinePlot("commitsChart", MetricUtils.getDateMetrics(r, false, null));\r
-               insertBarPlot("dayOfWeekChart", getDayOfWeekMetrics(r));\r
-               insertLinePlot("timeOfDayChart", getTimeOfDayMetrics(r));\r
-               insertPieChart("authorsChart", getAuthorMetrics(r));\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
+               } 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
+               }\r
+               insertLinePlot("commitsChart", metrics);\r
+               insertBarPlot("dayOfWeekChart", getDayOfWeekMetrics(r, objectId));\r
+               insertPieChart("authorsChart", getAuthorMetrics(r, objectId));\r
        }\r
 \r
        private void insertLinePlot(String wicketId, List<Metric> metrics) {\r
@@ -118,8 +129,8 @@ public class MetricsPage extends RepositoryPage {
                }\r
        }\r
 \r
-       private List<Metric> getDayOfWeekMetrics(Repository repository) {\r
-               List<Metric> list = MetricUtils.getDateMetrics(repository, false, "E");\r
+       private List<Metric> getDayOfWeekMetrics(Repository repository, String objectId) {\r
+               List<Metric> list = MetricUtils.getDateMetrics(repository, objectId, false, "E");\r
                SimpleDateFormat sdf = new SimpleDateFormat("E");\r
                Calendar cal = Calendar.getInstance();\r
 \r
@@ -143,35 +154,15 @@ public class MetricsPage extends RepositoryPage {
                return sorted;\r
        }\r
 \r
-       private List<Metric> getTimeOfDayMetrics(Repository repository) {\r
-               SimpleDateFormat ndf = new SimpleDateFormat("yyyy-MM-dd");\r
-               SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");\r
-               List<Metric> list = MetricUtils.getDateMetrics(repository, false, "yyyy-MM-dd HH:mm");\r
-               Calendar cal = Calendar.getInstance();\r
-\r
-               for (Metric metric : list) {\r
-                       try {\r
-                               Date date = sdf.parse(metric.name);\r
-                               cal.setTime(date);\r
-                               double y = cal.get(Calendar.HOUR_OF_DAY) + (cal.get(Calendar.MINUTE) / 60d);\r
-                               metric.duration = (int) (date.getTime() / 60000L);\r
-                               metric.count = y;\r
-                               metric.name = ndf.format(date);\r
-                       } catch (ParseException p) {\r
-                       }\r
-               }\r
-               return list;\r
-       }\r
-\r
-       private List<Metric> getAuthorMetrics(Repository repository) {\r
-               List<Metric> authors = MetricUtils.getAuthorMetrics(repository, true);\r
+       private List<Metric> getAuthorMetrics(Repository repository, String objectId) {\r
+               List<Metric> authors = MetricUtils.getAuthorMetrics(repository, objectId, true);\r
                Collections.sort(authors, new Comparator<Metric>() {\r
                        @Override\r
                        public int compare(Metric o1, Metric o2) {\r
                                if (o1.count > o2.count) {\r
                                        return -1;\r
                                } else if (o1.count < o2.count) {\r
-                                       return 1;                                       \r
+                                       return 1;\r
                                }\r
                                return 0;\r
                        }\r
index ffb484f1c0c1ea45833ea165a5d20248adf75891..0e0ce476e9ff494b0deec0acb6b9773f051e5b89 100644 (file)
@@ -18,7 +18,7 @@
                \r
                        <!-- page nav links -->\r
                        <div class="page_nav">          \r
-                               <a wicket:id="summary"><wicket:message key="gb.summary"></wicket:message></a> | <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="branches"><wicket:message key="gb.branches"></wicket:message></a> | <a wicket:id="tags"><wicket:message key="gb.tags"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a>  | <a wicket:id="metrics"><wicket:message key="gb.metrics"></wicket:message></a> <span wicket:id="extra"><span wicket:id="extraSeparator"></span><span wicket:id="extraLink"></span></span>\r
+                               <a wicket:id="summary"><wicket:message key="gb.summary"></wicket:message></a> | <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="branches"><wicket:message key="gb.branches"></wicket:message></a> | <a wicket:id="tags"><wicket:message key="gb.tags"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a> <span wicket:id="extra"><span wicket:id="extraSeparator"></span><span wicket:id="extraLink"></span></span>\r
                        </div>\r
                </div>\r
                \r
index eceda99873f97eecd7847b1bc02dfc9a818726b0..3ceb9f5fb216e2fc6c908b9111a91cae55e4b435 100644 (file)
@@ -76,7 +76,6 @@ public abstract class RepositoryPage extends BasePage {
                        put("branches", "gb.branches");\r
                        put("tags", "gb.tags");\r
                        put("tree", "gb.tree");\r
-                       put("metrics", "gb.metrics");\r
                        put("tickets", "gb.tickets");\r
                        put("edit", "gb.edit");\r
                }\r
@@ -105,8 +104,6 @@ public abstract class RepositoryPage extends BasePage {
                                WicketUtils.newRepositoryParameter(repositoryName)));\r
                add(new BookmarkablePageLink<Void>("tree", TreePage.class,\r
                                WicketUtils.newRepositoryParameter(repositoryName)));\r
-               add(new BookmarkablePageLink<Void>("metrics", MetricsPage.class,\r
-                               WicketUtils.newRepositoryParameter(repositoryName)));\r
 \r
                // per-repository extra page links\r
                List<String> extraPageLinks = new ArrayList<String>();\r
index 7d5629b61145f8bca20049413bc0a446b72f91c3..7784a4711e4feaebe51c72a6b5cdf1fa93806b93 100644 (file)
@@ -25,7 +25,7 @@
                                <tr><th><wicket:message key="gb.description">[description]</wicket:message></th><td><span wicket:id="repositoryDescription">[repository description]</span></td></tr>\r
                                <tr><th><wicket:message key="gb.owner">[owner]</wicket:message></th><td><span wicket:id="repositoryOwner">[repository owner]</span></td></tr>\r
                                <tr><th><wicket:message key="gb.lastChange">[last change]</wicket:message></th><td><span wicket:id="repositoryLastChange">[repository last change]</span></td></tr>\r
-                               <tr><th><wicket:message key="gb.metrics">[metrics]</wicket:message></th><td><span wicket:id="repositoryMetrics">[repository metrics]</span></td></tr>\r
+                               <tr><th><wicket:message key="gb.stats">[stats]</wicket:message></th><td><span wicket:id="branchStats">[branch stats]</span> <span class="link"><a wicket:id="metrics"><wicket:message key="gb.metrics">[metrics]</wicket:message></a></span></td></tr>\r
                                <tr><th valign="top"><wicket:message key="gb.url">[URL]</wicket:message></th><td><img style="vertical-align: top; padding-right:5px;" wicket:id="accessRestrictionIcon" /><span wicket:id="repositoryCloneUrl">[repository clone url]</span></td></tr>\r
                        </table>\r
                </div>\r
index fd21ed64c0c4b2b33aaa34dd88610c263e249238..03b1b1c7c6c763b8156aea6b11c322655ff4aee9 100644 (file)
@@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletRequest;
 \r
 import org.apache.wicket.PageParameters;\r
 import org.apache.wicket.markup.html.basic.Label;\r
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
 import org.apache.wicket.protocol.http.WebRequest;\r
 import org.eclipse.jgit.lib.Repository;\r
 import org.eclipse.jgit.revwalk.RevCommit;\r
@@ -77,7 +78,7 @@ public class SummaryPage extends RepositoryPage {
                List<Metric> metrics = null;\r
                Metric metricsTotal = null;\r
                if (GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {\r
-                       metrics = MetricUtils.getDateMetrics(r, true, null);\r
+                       metrics = MetricUtils.getDateMetrics(r, null, true, null);\r
                        metricsTotal = metrics.remove(0);\r
                }\r
 \r
@@ -88,12 +89,13 @@ public class SummaryPage extends RepositoryPage {
                add(WicketUtils.createTimestampLabel("repositoryLastChange", JGitUtils.getLastChange(r),\r
                                getTimeZone()));\r
                if (metricsTotal == null) {\r
-                       add(new Label("repositoryMetrics", ""));\r
+                       add(new Label("branchStats", ""));                      \r
                } else {\r
-                       add(new Label("repositoryMetrics", MessageFormat.format(\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
                }\r
+               add(new BookmarkablePageLink<Void>("metrics", MetricsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
 \r
                List<String> repositoryUrls = new ArrayList<String>();\r
 \r
@@ -141,8 +143,8 @@ public class SummaryPage extends RepositoryPage {
                                .setEscapeModelStrings(false));\r
 \r
                add(new LogPanel("commitsPanel", repositoryName, null, r, numberCommits, 0));\r
-               add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs));\r
-               add(new BranchesPanel("branchesPanel", getRepositoryModel(), r, numberRefs));\r
+               add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs).hideIfEmpty());\r
+               add(new BranchesPanel("branchesPanel", getRepositoryModel(), r, numberRefs).hideIfEmpty());\r
 \r
                if (getRepositoryModel().showReadme) {\r
                        String htmlText = null;\r
index 497003a5763ecc6eb3f0532d2cc523507f863d97..91c34d2d80ef2c04a04ea25343c2bbb9fc6124bc 100644 (file)
                        <td><span wicket:id="branchName">[branch name]</span></td>\r
                        <td><span wicket:id="branchType">[branch type]</span></td>\r
                        <td class="rightAlign">\r
-                               <span class="link">\r
-                                               <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a>\r
-                                       </span> \r
+                               <span wicket:id="branchLinks"></span>\r
                                </td>\r
                        </tr>\r
        </tbody>\r
        </table>        \r
 \r
        <div wicket:id="allBranches">[all branches]</div>       \r
-               \r
+\r
+       <!-- branch page links -->\r
+       <wicket:fragment wicket:id="branchPageLinks">\r
+               <span class="link">\r
+                       <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a> | <a wicket:id="metrics"><wicket:message key="gb.metrics"></wicket:message></a>\r
+               </span>\r
+       </wicket:fragment>\r
+\r
+       <!-- branch panel links -->\r
+       <wicket:fragment wicket:id="branchPanelLinks">\r
+               <span class="link">\r
+                       <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a>\r
+               </span>\r
+       </wicket:fragment>\r
+                       \r
 </wicket:panel>\r
 </body>\r
 </html>
\ No newline at end of file
index 82f8a04559a685b643dc04ae30d2c46009cf9704..b11c03ab39170f4af33074c0b98bc827a08e030e 100644 (file)
@@ -21,6 +21,7 @@ import java.util.List;
 \r
 import org.apache.wicket.markup.html.basic.Label;\r
 import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
+import org.apache.wicket.markup.html.panel.Fragment;\r
 import org.apache.wicket.markup.repeater.Item;\r
 import org.apache.wicket.markup.repeater.data.DataView;\r
 import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
@@ -35,6 +36,7 @@ import com.gitblit.utils.StringUtils;
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.pages.BranchesPage;\r
 import com.gitblit.wicket.pages.LogPage;\r
+import com.gitblit.wicket.pages.MetricsPage;\r
 import com.gitblit.wicket.pages.SummaryPage;\r
 import com.gitblit.wicket.pages.TreePage;\r
 \r
@@ -42,6 +44,8 @@ public class BranchesPanel extends BasePanel {
 \r
        private static final long serialVersionUID = 1L;\r
 \r
+       private final boolean hasBranches;\r
+\r
        public BranchesPanel(String wicketId, final RepositoryModel model, Repository r,\r
                        final int maxCount) {\r
                super(wicketId);\r
@@ -89,11 +93,23 @@ public class BranchesPanel extends BasePanel {
                                item.add(new Label("branchType", remote ? getString("gb.remote")\r
                                                : getString("gb.local")).setVisible(maxCount <= 0));\r
 \r
-                               item.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils\r
-                                               .newObjectParameter(model.name, entry.getName())));\r
-                               item.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils\r
-                                               .newObjectParameter(model.name, entry.getName())));\r
-\r
+                               if (maxCount <= 0) {\r
+                                       Fragment fragment = new Fragment("branchLinks", "branchPageLinks", this);\r
+                                       fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils\r
+                                                       .newObjectParameter(model.name, entry.getName())));\r
+                                       fragment.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils\r
+                                                       .newObjectParameter(model.name, entry.getName())));\r
+                                       fragment.add(new BookmarkablePageLink<Void>("metrics", MetricsPage.class,\r
+                                                       WicketUtils.newObjectParameter(model.name, entry.getName())));\r
+                                       item.add(fragment);\r
+                               } else {\r
+                                       Fragment fragment = new Fragment("branchLinks", "branchPanelLinks", this);\r
+                                       fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils\r
+                                                       .newObjectParameter(model.name, entry.getName())));\r
+                                       fragment.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils\r
+                                                       .newObjectParameter(model.name, entry.getName())));\r
+                                       item.add(fragment);\r
+                               }\r
                                WicketUtils.setAlternatingBackground(item, counter);\r
                                counter++;\r
                        }\r
@@ -105,5 +121,12 @@ public class BranchesPanel extends BasePanel {
                        add(new LinkPanel("allBranches", "link", new StringResourceModel("gb.allBranches",\r
                                        this, null), BranchesPage.class, WicketUtils.newRepositoryParameter(model.name)));\r
                }\r
+               // We always have 1 branch\r
+               hasBranches = branches.size() > 1;\r
+       }\r
+\r
+       public BranchesPanel hideIfEmpty() {\r
+               setVisible(hasBranches);\r
+               return this;\r
        }\r
 }\r
index 8cf137b16d1edb06528aebd2b9bf15c816849c8c..f25b53b2e032d785d0ed786b72c08fc4474141b8 100644 (file)
@@ -70,19 +70,19 @@ public class RefsPanel extends Panel {
                                Class<? extends RepositoryPage> linkClass = CommitPage.class;\r
                                String cssClass = "";\r
                                if (name.startsWith(Constants.R_HEADS)) {\r
-                                       // local head\r
+                                       // local branch\r
                                        linkClass = LogPage.class;\r
                                        name = name.substring(Constants.R_HEADS.length());\r
-                                       cssClass = "headRef";\r
+                                       cssClass = "localBranch";\r
                                } else if (name.equals(Constants.HEAD)) {\r
                                        // local head\r
                                        linkClass = LogPage.class;\r
                                        cssClass = "headRef";\r
                                } else if (name.startsWith(Constants.R_REMOTES)) {\r
-                                       // remote head\r
+                                       // remote branch\r
                                        linkClass = LogPage.class;\r
                                        name = name.substring(Constants.R_REMOTES.length());\r
-                                       cssClass = "remoteRef";\r
+                                       cssClass = "remoteBranch";\r
                                } else if (name.startsWith(Constants.R_TAGS)) {\r
                                        // tag\r
                                        if (entry.isAnnotatedTag()) {\r
index f6dd762bb585c1d37adc5e57be2539ea17505c5c..4504c5116ea12c2ee76587810a85b7c7e7e35ce3 100644 (file)
@@ -44,6 +44,8 @@ import com.gitblit.wicket.pages.TreePage;
 public class TagsPanel extends BasePanel {\r
 \r
        private static final long serialVersionUID = 1L;\r
+       \r
+       private final boolean hasTags;\r
 \r
        public TagsPanel(String wicketId, final String repositoryName, Repository r, final int maxCount) {\r
                super(wicketId);\r
@@ -162,5 +164,12 @@ 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
+               hasTags = tags.size() > 0;\r
+       }\r
+       \r
+       public TagsPanel hideIfEmpty() {\r
+               setVisible(hasTags);\r
+               return this;\r
        }\r
 }\r
index 5dd0f160b14d0e14f40d8aab427e3c2447107433..a0ab10ab6453006ef7a95b2b0deb19682950193d 100644 (file)
@@ -708,7 +708,11 @@ td.treeLinks {
        width: 13em;\r
 }\r
 \r
-span .tagRef, span .headRef, span .remoteRef, span .otherRef { \r
+span.metricsTitle {\r
+       font-size: 2em;\r
+}\r
+\r
+span .tagRef, span .headRef, span .localBranch, span .remoteBranch, span .otherRef {   \r
        padding: 0px 3px;\r
        margin-right:2px;\r
        font-family: sans-serif;\r
@@ -718,26 +722,26 @@ span .tagRef, span .headRef, span .remoteRef, span .otherRef {
        color: black;   \r
 }\r
 \r
-span .tagRef a span, span .headRef a span, span .remoteRef a span, span .otherRef a span {\r
+span .tagRef a span, span .headRef a span, span .localBranch a span, span .remoteBranch a span, span .otherRef a span {\r
        font-size: 9px;\r
 }\r
 \r
-span .tagRef a, span .headRef a, span .remoteRef a, span .otherRef a {\r
+span .tagRef a, span .headRef a, span .localBranch a, span .remoteBranch a, span .otherRef a {\r
        text-decoration: none;\r
        color: black !important;\r
 }\r
 \r
-span .tagRef a:hover, span .headRef a:hover, span .remoteRef a:hover, span .otherRef a:hover {\r
+span .tagRef a:hover, span .headRef a:hover, span .localBranch a:hover, span .remoteBranch a:hover, span .otherRef a:hover {\r
        color: black !important;\r
        text-decoration: underline;\r
 }\r
 \r
 span .otherRef {\r
-       background-color: #ffaaff;\r
-       border-color: #ff00ee;\r
+       background-color: #80ccdd;\r
+       border-color: #80aaaa;  \r
 }\r
 \r
-span .remoteRef {\r
+span .remoteBranch {\r
        background-color: #cAc2f5;\r
        border-color: #6c6cbf;\r
 }\r
@@ -748,6 +752,11 @@ span .tagRef {
 }\r
 \r
 span .headRef {\r
+       background-color: #ffaaff;\r
+       border-color: #ff00ee;\r
+}\r
+\r
+span .localBranch {\r
        background-color: #ccffcc;\r
        border-color: #00cc33;\r
 }\r
index 07cd60600b8a4f7a35bfdf1be58517d1c49b906c..db994b80cd9f639c524d034f2d198cdcb9ec73a6 100644 (file)
@@ -28,15 +28,15 @@ public class MetricUtilsTest extends TestCase {
 \r
        public void testMetrics() throws Exception {\r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
-               List<Metric> metrics = MetricUtils.getDateMetrics(repository, true, null);\r
+               List<Metric> metrics = MetricUtils.getDateMetrics(repository, null, true, null);\r
                repository.close();\r
                assertTrue("No date metrics found!", metrics.size() > 0);\r
        }\r
        \r
        public void testAuthorMetrics() throws Exception {\r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
-               List<Metric> byEmail = MetricUtils.getAuthorMetrics(repository, true);\r
-               List<Metric> byName = MetricUtils.getAuthorMetrics(repository, false);\r
+               List<Metric> byEmail = MetricUtils.getAuthorMetrics(repository, null, true);\r
+               List<Metric> byName = MetricUtils.getAuthorMetrics(repository, null, false);\r
                repository.close();\r
                assertTrue("No author metrics found!", byEmail.size() == 9);\r
                assertTrue("No author metrics found!", byName.size() == 8);\r