summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2011-06-07 20:55:19 -0400
committerJames Moger <james.moger@gitblit.com>2011-06-07 20:55:19 -0400
commit1fa5e85b2d208636a6237ef8930f200767165baa (patch)
tree8122ba9fae032b513f0e7bbfdba6c143104bac39
parent16856603ec575718857768e2d18e455c95fd6ea4 (diff)
downloadgitblit-1fa5e85b2d208636a6237ef8930f200767165baa.tar.gz
gitblit-1fa5e85b2d208636a6237ef8930f200767165baa.zip
Improved metrics page and added metrics links to branches panel.
-rw-r--r--docs/00_index.mkd1
-rw-r--r--src/com/gitblit/models/RefModel.java5
-rw-r--r--src/com/gitblit/utils/MetricUtils.java21
-rw-r--r--src/com/gitblit/wicket/GitBlitWebApp.properties6
-rw-r--r--src/com/gitblit/wicket/pages/MetricsPage.html26
-rw-r--r--src/com/gitblit/wicket/pages/MetricsPage.java55
-rw-r--r--src/com/gitblit/wicket/pages/RepositoryPage.html2
-rw-r--r--src/com/gitblit/wicket/pages/RepositoryPage.java3
-rw-r--r--src/com/gitblit/wicket/pages/SummaryPage.html2
-rw-r--r--src/com/gitblit/wicket/pages/SummaryPage.java12
-rw-r--r--src/com/gitblit/wicket/panels/BranchesPanel.html20
-rw-r--r--src/com/gitblit/wicket/panels/BranchesPanel.java33
-rw-r--r--src/com/gitblit/wicket/panels/RefsPanel.java8
-rw-r--r--src/com/gitblit/wicket/panels/TagsPanel.java9
-rw-r--r--src/com/gitblit/wicket/resources/gitblit.css23
-rw-r--r--tests/com/gitblit/tests/MetricUtilsTest.java6
16 files changed, 148 insertions, 84 deletions
diff --git a/docs/00_index.mkd b/docs/00_index.mkd
index 8c8f9322..d1331636 100644
--- a/docs/00_index.mkd
+++ b/docs/00_index.mkd
@@ -56,7 +56,6 @@ sources @ [Github][gitbltsrc]
### Todo List
- Code documentation
- Unit testing
-- Branch selector on Metrics
- Blame
- Clone remote repository
diff --git a/src/com/gitblit/models/RefModel.java b/src/com/gitblit/models/RefModel.java
index 39bf19c9..0b65c092 100644
--- a/src/com/gitblit/models/RefModel.java
+++ b/src/com/gitblit/models/RefModel.java
@@ -127,4 +127,9 @@ public class RefModel implements Serializable, Comparable<RefModel> {
public int compareTo(RefModel o) {
return getDate().compareTo(o.getDate());
}
+
+ @Override
+ public String toString() {
+ return displayName;
+ }
} \ No newline at end of file
diff --git a/src/com/gitblit/utils/MetricUtils.java b/src/com/gitblit/utils/MetricUtils.java
index d8286e29..492b0243 100644
--- a/src/com/gitblit/utils/MetricUtils.java
+++ b/src/com/gitblit/utils/MetricUtils.java
@@ -39,10 +39,12 @@ public class MetricUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(MetricUtils.class);
- public static List<Metric> getDateMetrics(Repository r, boolean includeTotal, String format) {
+ public static List<Metric> getDateMetrics(Repository r, String objectId, boolean includeTotal, String format) {
Metric total = new Metric("TOTAL");
final Map<String, Metric> metricMap = new HashMap<String, Metric>();
-
+ if (StringUtils.isEmpty(objectId)) {
+ objectId = Constants.HEAD;
+ }
if (JGitUtils.hasCommits(r)) {
final List<RefModel> tags = JGitUtils.getTags(r, true, -1);
final Map<ObjectId, RefModel> tagMap = new HashMap<ObjectId, RefModel>();
@@ -51,7 +53,7 @@ public class MetricUtils {
}
try {
RevWalk walk = new RevWalk(r);
- ObjectId object = r.resolve(Constants.HEAD);
+ ObjectId object = r.resolve(objectId);
RevCommit lastCommit = walk.parseCommit(object);
walk.markStart(lastCommit);
@@ -62,12 +64,9 @@ public class MetricUtils {
int diffDays = (lastCommit.getCommitTime() - firstCommit.getCommitTime())
/ (60 * 60 * 24);
total.duration = diffDays;
- if (diffDays <= 90) {
+ if (diffDays <= 365) {
// Days
df = new SimpleDateFormat("yyyy-MM-dd");
- } else if (diffDays > 90 && diffDays < 365) {
- // Weeks
- df = new SimpleDateFormat("yyyy-MM (w)");
} else {
// Months
df = new SimpleDateFormat("yyyy-MM");
@@ -108,13 +107,15 @@ public class MetricUtils {
return metrics;
}
- public static List<Metric> getAuthorMetrics(Repository r, boolean byEmail) {
+ public static List<Metric> getAuthorMetrics(Repository r, String objectId, boolean byEmail) {
final Map<String, Metric> metricMap = new HashMap<String, Metric>();
-
+ if (StringUtils.isEmpty(objectId)) {
+ objectId = Constants.HEAD;
+ }
if (JGitUtils.hasCommits(r)) {
try {
RevWalk walk = new RevWalk(r);
- ObjectId object = r.resolve(Constants.HEAD);
+ ObjectId object = r.resolve(objectId);
RevCommit lastCommit = walk.parseCommit(object);
walk.markStart(lastCommit);
diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties
index f64f1e56..d6102dbf 100644
--- a/src/com/gitblit/wicket/GitBlitWebApp.properties
+++ b/src/com/gitblit/wicket/GitBlitWebApp.properties
@@ -55,6 +55,7 @@ gb.modification = modification
gb.deletion = deletion
gb.rename = rename
gb.metrics = metrics
+gb.stats = stats
gb.markdown = markdown
gb.changedFiles = changed files
gb.filesAdded = {0} files added
@@ -94,4 +95,7 @@ gb.showReadme = show readme
gb.showReadmeDescription = show a \"readme\" markdown file on the summary page
gb.nameDescription = use '/' to group repositories. e.g. libraries/mycoollib.git
gb.ownerDescription = the owner may edit repository settings
-gb.blob = blob \ No newline at end of file
+gb.blob = blob
+gb.commitActivityTrend = commit activity trend
+gb.commitActivityDOW = commit activity by day of week
+gb.commitActivityAuthors = primary authors by commit activity \ No newline at end of file
diff --git a/src/com/gitblit/wicket/pages/MetricsPage.html b/src/com/gitblit/wicket/pages/MetricsPage.html
index d6f23e01..734b9fad 100644
--- a/src/com/gitblit/wicket/pages/MetricsPage.html
+++ b/src/com/gitblit/wicket/pages/MetricsPage.html
@@ -6,18 +6,30 @@
<body>
<wicket:extend>
- <h2>Commit Activity</h2>
+ <div style="padding-top:10px;">
+ <!-- branch name -->
+ <div><span class="metricsTitle" wicket:id="branchTitle"></span></div>
+
+ <!-- placeholder for more info -->
+ <div style="float:right;width:200px;text-align: left;">
+ </div>
+
+ <!-- branch stats -->
+ <h2><wicket:message key="gb.stats"></wicket:message></h2>
+ <span wicket:id="branchStats"></span>
+
+ <!-- commit activity trend -->
+ <h2><wicket:message key="gb.commitActivityTrend"></wicket:message></h2>
<div><img wicket:id="commitsChart" /></div>
- <h2>Commit Activity by Day of Week</h2>
+ <!-- commit activity by day of week -->
+ <h2><wicket:message key="gb.commitActivityDOW"></wicket:message></h2>
<div><img wicket:id="dayOfWeekChart" /></div>
- <h2>Commit Activity by Time of Day</h2>
- <div><img wicket:id="timeOfDayChart" /></div>
-
- <h2>Most Prolific Authors</h2>
+ <!-- commit activity by primary authors -->
+ <h2><wicket:message key="gb.commitActivityAuthors"></wicket:message></h2>
<div><img wicket:id="authorsChart" /></div>
-
+ </div>
</wicket:extend>
</body>
</html> \ No newline at end of file
diff --git a/src/com/gitblit/wicket/pages/MetricsPage.java b/src/com/gitblit/wicket/pages/MetricsPage.java
index c6231e9d..9dd10d1b 100644
--- a/src/com/gitblit/wicket/pages/MetricsPage.java
+++ b/src/com/gitblit/wicket/pages/MetricsPage.java
@@ -17,16 +17,16 @@ package com.gitblit.wicket.pages;
import java.awt.Color;
import java.awt.Dimension;
-import java.text.ParseException;
+import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
-import java.util.Date;
import java.util.List;
import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
import org.eclipse.jgit.lib.Repository;
import org.wicketstuff.googlecharts.Chart;
import org.wicketstuff.googlecharts.ChartAxis;
@@ -40,17 +40,28 @@ import org.wicketstuff.googlecharts.ShapeMarker;
import com.gitblit.models.Metric;
import com.gitblit.utils.MetricUtils;
+import com.gitblit.utils.TimeUtils;
import com.gitblit.wicket.WicketUtils;
public class MetricsPage extends RepositoryPage {
public MetricsPage(PageParameters params) {
- super(params);
+ super(params);
Repository r = getRepository();
- insertLinePlot("commitsChart", MetricUtils.getDateMetrics(r, false, null));
- insertBarPlot("dayOfWeekChart", getDayOfWeekMetrics(r));
- insertLinePlot("timeOfDayChart", getTimeOfDayMetrics(r));
- insertPieChart("authorsChart", getAuthorMetrics(r));
+ add(new Label("branchTitle", objectId));
+ Metric metricsTotal = null;
+ List<Metric> metrics = MetricUtils.getDateMetrics(r, objectId, true, null);
+ metricsTotal = metrics.remove(0);
+ if (metricsTotal == null) {
+ add(new Label("branchStats", ""));
+ } else {
+ add(new Label("branchStats", MessageFormat.format(
+ "{0} commits and {1} tags in {2}", metricsTotal.count, metricsTotal.tag,
+ TimeUtils.duration(metricsTotal.duration))));
+ }
+ insertLinePlot("commitsChart", metrics);
+ insertBarPlot("dayOfWeekChart", getDayOfWeekMetrics(r, objectId));
+ insertPieChart("authorsChart", getAuthorMetrics(r, objectId));
}
private void insertLinePlot(String wicketId, List<Metric> metrics) {
@@ -118,8 +129,8 @@ public class MetricsPage extends RepositoryPage {
}
}
- private List<Metric> getDayOfWeekMetrics(Repository repository) {
- List<Metric> list = MetricUtils.getDateMetrics(repository, false, "E");
+ private List<Metric> getDayOfWeekMetrics(Repository repository, String objectId) {
+ List<Metric> list = MetricUtils.getDateMetrics(repository, objectId, false, "E");
SimpleDateFormat sdf = new SimpleDateFormat("E");
Calendar cal = Calendar.getInstance();
@@ -143,35 +154,15 @@ public class MetricsPage extends RepositoryPage {
return sorted;
}
- private List<Metric> getTimeOfDayMetrics(Repository repository) {
- SimpleDateFormat ndf = new SimpleDateFormat("yyyy-MM-dd");
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
- List<Metric> list = MetricUtils.getDateMetrics(repository, false, "yyyy-MM-dd HH:mm");
- Calendar cal = Calendar.getInstance();
-
- for (Metric metric : list) {
- try {
- Date date = sdf.parse(metric.name);
- cal.setTime(date);
- double y = cal.get(Calendar.HOUR_OF_DAY) + (cal.get(Calendar.MINUTE) / 60d);
- metric.duration = (int) (date.getTime() / 60000L);
- metric.count = y;
- metric.name = ndf.format(date);
- } catch (ParseException p) {
- }
- }
- return list;
- }
-
- private List<Metric> getAuthorMetrics(Repository repository) {
- List<Metric> authors = MetricUtils.getAuthorMetrics(repository, true);
+ private List<Metric> getAuthorMetrics(Repository repository, String objectId) {
+ List<Metric> authors = MetricUtils.getAuthorMetrics(repository, objectId, true);
Collections.sort(authors, new Comparator<Metric>() {
@Override
public int compare(Metric o1, Metric o2) {
if (o1.count > o2.count) {
return -1;
} else if (o1.count < o2.count) {
- return 1;
+ return 1;
}
return 0;
}
diff --git a/src/com/gitblit/wicket/pages/RepositoryPage.html b/src/com/gitblit/wicket/pages/RepositoryPage.html
index ffb484f1..0e0ce476 100644
--- a/src/com/gitblit/wicket/pages/RepositoryPage.html
+++ b/src/com/gitblit/wicket/pages/RepositoryPage.html
@@ -18,7 +18,7 @@
<!-- page nav links -->
<div class="page_nav">
- <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>
+ <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>
</div>
</div>
diff --git a/src/com/gitblit/wicket/pages/RepositoryPage.java b/src/com/gitblit/wicket/pages/RepositoryPage.java
index eceda998..3ceb9f5f 100644
--- a/src/com/gitblit/wicket/pages/RepositoryPage.java
+++ b/src/com/gitblit/wicket/pages/RepositoryPage.java
@@ -76,7 +76,6 @@ public abstract class RepositoryPage extends BasePage {
put("branches", "gb.branches");
put("tags", "gb.tags");
put("tree", "gb.tree");
- put("metrics", "gb.metrics");
put("tickets", "gb.tickets");
put("edit", "gb.edit");
}
@@ -105,8 +104,6 @@ public abstract class RepositoryPage extends BasePage {
WicketUtils.newRepositoryParameter(repositoryName)));
add(new BookmarkablePageLink<Void>("tree", TreePage.class,
WicketUtils.newRepositoryParameter(repositoryName)));
- add(new BookmarkablePageLink<Void>("metrics", MetricsPage.class,
- WicketUtils.newRepositoryParameter(repositoryName)));
// per-repository extra page links
List<String> extraPageLinks = new ArrayList<String>();
diff --git a/src/com/gitblit/wicket/pages/SummaryPage.html b/src/com/gitblit/wicket/pages/SummaryPage.html
index 7d5629b6..7784a471 100644
--- a/src/com/gitblit/wicket/pages/SummaryPage.html
+++ b/src/com/gitblit/wicket/pages/SummaryPage.html
@@ -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>
<tr><th><wicket:message key="gb.owner">[owner]</wicket:message></th><td><span wicket:id="repositoryOwner">[repository owner]</span></td></tr>
<tr><th><wicket:message key="gb.lastChange">[last change]</wicket:message></th><td><span wicket:id="repositoryLastChange">[repository last change]</span></td></tr>
- <tr><th><wicket:message key="gb.metrics">[metrics]</wicket:message></th><td><span wicket:id="repositoryMetrics">[repository metrics]</span></td></tr>
+ <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>
<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>
</table>
</div>
diff --git a/src/com/gitblit/wicket/pages/SummaryPage.java b/src/com/gitblit/wicket/pages/SummaryPage.java
index fd21ed64..03b1b1c7 100644
--- a/src/com/gitblit/wicket/pages/SummaryPage.java
+++ b/src/com/gitblit/wicket/pages/SummaryPage.java
@@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.protocol.http.WebRequest;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -77,7 +78,7 @@ public class SummaryPage extends RepositoryPage {
List<Metric> metrics = null;
Metric metricsTotal = null;
if (GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {
- metrics = MetricUtils.getDateMetrics(r, true, null);
+ metrics = MetricUtils.getDateMetrics(r, null, true, null);
metricsTotal = metrics.remove(0);
}
@@ -88,12 +89,13 @@ public class SummaryPage extends RepositoryPage {
add(WicketUtils.createTimestampLabel("repositoryLastChange", JGitUtils.getLastChange(r),
getTimeZone()));
if (metricsTotal == null) {
- add(new Label("repositoryMetrics", ""));
+ add(new Label("branchStats", ""));
} else {
- add(new Label("repositoryMetrics", MessageFormat.format(
+ add(new Label("branchStats", MessageFormat.format(
"{0} commits and {1} tags in {2}", metricsTotal.count, metricsTotal.tag,
TimeUtils.duration(metricsTotal.duration))));
}
+ add(new BookmarkablePageLink<Void>("metrics", MetricsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
List<String> repositoryUrls = new ArrayList<String>();
@@ -141,8 +143,8 @@ public class SummaryPage extends RepositoryPage {
.setEscapeModelStrings(false));
add(new LogPanel("commitsPanel", repositoryName, null, r, numberCommits, 0));
- add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs));
- add(new BranchesPanel("branchesPanel", getRepositoryModel(), r, numberRefs));
+ add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs).hideIfEmpty());
+ add(new BranchesPanel("branchesPanel", getRepositoryModel(), r, numberRefs).hideIfEmpty());
if (getRepositoryModel().showReadme) {
String htmlText = null;
diff --git a/src/com/gitblit/wicket/panels/BranchesPanel.html b/src/com/gitblit/wicket/panels/BranchesPanel.html
index 497003a5..91c34d2d 100644
--- a/src/com/gitblit/wicket/panels/BranchesPanel.html
+++ b/src/com/gitblit/wicket/panels/BranchesPanel.html
@@ -17,16 +17,28 @@
<td><span wicket:id="branchName">[branch name]</span></td>
<td><span wicket:id="branchType">[branch type]</span></td>
<td class="rightAlign">
- <span class="link">
- <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a>
- </span>
+ <span wicket:id="branchLinks"></span>
</td>
</tr>
</tbody>
</table>
<div wicket:id="allBranches">[all branches]</div>
-
+
+ <!-- branch page links -->
+ <wicket:fragment wicket:id="branchPageLinks">
+ <span class="link">
+ <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>
+ </span>
+ </wicket:fragment>
+
+ <!-- branch panel links -->
+ <wicket:fragment wicket:id="branchPanelLinks">
+ <span class="link">
+ <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a>
+ </span>
+ </wicket:fragment>
+
</wicket:panel>
</body>
</html> \ No newline at end of file
diff --git a/src/com/gitblit/wicket/panels/BranchesPanel.java b/src/com/gitblit/wicket/panels/BranchesPanel.java
index 82f8a045..b11c03ab 100644
--- a/src/com/gitblit/wicket/panels/BranchesPanel.java
+++ b/src/com/gitblit/wicket/panels/BranchesPanel.java
@@ -21,6 +21,7 @@ import java.util.List;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
@@ -35,6 +36,7 @@ import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.pages.BranchesPage;
import com.gitblit.wicket.pages.LogPage;
+import com.gitblit.wicket.pages.MetricsPage;
import com.gitblit.wicket.pages.SummaryPage;
import com.gitblit.wicket.pages.TreePage;
@@ -42,6 +44,8 @@ public class BranchesPanel extends BasePanel {
private static final long serialVersionUID = 1L;
+ private final boolean hasBranches;
+
public BranchesPanel(String wicketId, final RepositoryModel model, Repository r,
final int maxCount) {
super(wicketId);
@@ -89,11 +93,23 @@ public class BranchesPanel extends BasePanel {
item.add(new Label("branchType", remote ? getString("gb.remote")
: getString("gb.local")).setVisible(maxCount <= 0));
- item.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils
- .newObjectParameter(model.name, entry.getName())));
- item.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils
- .newObjectParameter(model.name, entry.getName())));
-
+ if (maxCount <= 0) {
+ Fragment fragment = new Fragment("branchLinks", "branchPageLinks", this);
+ fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils
+ .newObjectParameter(model.name, entry.getName())));
+ fragment.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils
+ .newObjectParameter(model.name, entry.getName())));
+ fragment.add(new BookmarkablePageLink<Void>("metrics", MetricsPage.class,
+ WicketUtils.newObjectParameter(model.name, entry.getName())));
+ item.add(fragment);
+ } else {
+ Fragment fragment = new Fragment("branchLinks", "branchPanelLinks", this);
+ fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils
+ .newObjectParameter(model.name, entry.getName())));
+ fragment.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils
+ .newObjectParameter(model.name, entry.getName())));
+ item.add(fragment);
+ }
WicketUtils.setAlternatingBackground(item, counter);
counter++;
}
@@ -105,5 +121,12 @@ public class BranchesPanel extends BasePanel {
add(new LinkPanel("allBranches", "link", new StringResourceModel("gb.allBranches",
this, null), BranchesPage.class, WicketUtils.newRepositoryParameter(model.name)));
}
+ // We always have 1 branch
+ hasBranches = branches.size() > 1;
+ }
+
+ public BranchesPanel hideIfEmpty() {
+ setVisible(hasBranches);
+ return this;
}
}
diff --git a/src/com/gitblit/wicket/panels/RefsPanel.java b/src/com/gitblit/wicket/panels/RefsPanel.java
index 8cf137b1..f25b53b2 100644
--- a/src/com/gitblit/wicket/panels/RefsPanel.java
+++ b/src/com/gitblit/wicket/panels/RefsPanel.java
@@ -70,19 +70,19 @@ public class RefsPanel extends Panel {
Class<? extends RepositoryPage> linkClass = CommitPage.class;
String cssClass = "";
if (name.startsWith(Constants.R_HEADS)) {
- // local head
+ // local branch
linkClass = LogPage.class;
name = name.substring(Constants.R_HEADS.length());
- cssClass = "headRef";
+ cssClass = "localBranch";
} else if (name.equals(Constants.HEAD)) {
// local head
linkClass = LogPage.class;
cssClass = "headRef";
} else if (name.startsWith(Constants.R_REMOTES)) {
- // remote head
+ // remote branch
linkClass = LogPage.class;
name = name.substring(Constants.R_REMOTES.length());
- cssClass = "remoteRef";
+ cssClass = "remoteBranch";
} else if (name.startsWith(Constants.R_TAGS)) {
// tag
if (entry.isAnnotatedTag()) {
diff --git a/src/com/gitblit/wicket/panels/TagsPanel.java b/src/com/gitblit/wicket/panels/TagsPanel.java
index f6dd762b..4504c511 100644
--- a/src/com/gitblit/wicket/panels/TagsPanel.java
+++ b/src/com/gitblit/wicket/panels/TagsPanel.java
@@ -44,6 +44,8 @@ import com.gitblit.wicket.pages.TreePage;
public class TagsPanel extends BasePanel {
private static final long serialVersionUID = 1L;
+
+ private final boolean hasTags;
public TagsPanel(String wicketId, final String repositoryName, Repository r, final int maxCount) {
super(wicketId);
@@ -162,5 +164,12 @@ public class TagsPanel extends BasePanel {
add(new LinkPanel("allTags", "link", new StringResourceModel("gb.allTags", this, null),
TagsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
}
+
+ hasTags = tags.size() > 0;
+ }
+
+ public TagsPanel hideIfEmpty() {
+ setVisible(hasTags);
+ return this;
}
}
diff --git a/src/com/gitblit/wicket/resources/gitblit.css b/src/com/gitblit/wicket/resources/gitblit.css
index 5dd0f160..a0ab10ab 100644
--- a/src/com/gitblit/wicket/resources/gitblit.css
+++ b/src/com/gitblit/wicket/resources/gitblit.css
@@ -708,7 +708,11 @@ td.treeLinks {
width: 13em;
}
-span .tagRef, span .headRef, span .remoteRef, span .otherRef {
+span.metricsTitle {
+ font-size: 2em;
+}
+
+span .tagRef, span .headRef, span .localBranch, span .remoteBranch, span .otherRef {
padding: 0px 3px;
margin-right:2px;
font-family: sans-serif;
@@ -718,26 +722,26 @@ span .tagRef, span .headRef, span .remoteRef, span .otherRef {
color: black;
}
-span .tagRef a span, span .headRef a span, span .remoteRef a span, span .otherRef a span {
+span .tagRef a span, span .headRef a span, span .localBranch a span, span .remoteBranch a span, span .otherRef a span {
font-size: 9px;
}
-span .tagRef a, span .headRef a, span .remoteRef a, span .otherRef a {
+span .tagRef a, span .headRef a, span .localBranch a, span .remoteBranch a, span .otherRef a {
text-decoration: none;
color: black !important;
}
-span .tagRef a:hover, span .headRef a:hover, span .remoteRef a:hover, span .otherRef a:hover {
+span .tagRef a:hover, span .headRef a:hover, span .localBranch a:hover, span .remoteBranch a:hover, span .otherRef a:hover {
color: black !important;
text-decoration: underline;
}
span .otherRef {
- background-color: #ffaaff;
- border-color: #ff00ee;
+ background-color: #80ccdd;
+ border-color: #80aaaa;
}
-span .remoteRef {
+span .remoteBranch {
background-color: #cAc2f5;
border-color: #6c6cbf;
}
@@ -748,6 +752,11 @@ span .tagRef {
}
span .headRef {
+ background-color: #ffaaff;
+ border-color: #ff00ee;
+}
+
+span .localBranch {
background-color: #ccffcc;
border-color: #00cc33;
}
diff --git a/tests/com/gitblit/tests/MetricUtilsTest.java b/tests/com/gitblit/tests/MetricUtilsTest.java
index 07cd6060..db994b80 100644
--- a/tests/com/gitblit/tests/MetricUtilsTest.java
+++ b/tests/com/gitblit/tests/MetricUtilsTest.java
@@ -28,15 +28,15 @@ public class MetricUtilsTest extends TestCase {
public void testMetrics() throws Exception {
Repository repository = GitBlitSuite.getHelloworldRepository();
- List<Metric> metrics = MetricUtils.getDateMetrics(repository, true, null);
+ List<Metric> metrics = MetricUtils.getDateMetrics(repository, null, true, null);
repository.close();
assertTrue("No date metrics found!", metrics.size() > 0);
}
public void testAuthorMetrics() throws Exception {
Repository repository = GitBlitSuite.getHelloworldRepository();
- List<Metric> byEmail = MetricUtils.getAuthorMetrics(repository, true);
- List<Metric> byName = MetricUtils.getAuthorMetrics(repository, false);
+ List<Metric> byEmail = MetricUtils.getAuthorMetrics(repository, null, true);
+ List<Metric> byName = MetricUtils.getAuthorMetrics(repository, null, false);
repository.close();
assertTrue("No author metrics found!", byEmail.size() == 9);
assertTrue("No author metrics found!", byName.size() == 8);