The Unified and Autonomous Development Platform
Add branches page
steve6d1538c6f653
diff --git a/commons.git/src/main/java/com/pmease/commons/git/UserInfo.java b/commons.git/src/main/java/com/pmease/commons/git/UserInfo.javaindex 72495b5a3e..245c1d2743 100644--- a/commons.git/src/main/java/com/pmease/commons/git/UserInfo.java+++ b/commons.git/src/main/java/com/pmease/commons/git/UserInfo.java@@ -52,7 +52,10 @@ public class UserInfo implements Serializable {@Overridepublic String toString() {return Objects.toStringHelper(this)- .add("name", name).toString();+ .add("name", name)+ .add("email", email)+ .add("date", date)+ .toString();}}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/base.css b/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/base.cssindex 9916d35f70..e06fb91087 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/base.css+++ b/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/base.css@@ -26,6 +26,9 @@ ul.disc { list-style:disc outside; }.text-nowrap { white-space: nowrap; }+hr.dash { border-style: dashed; }+hr.deep { border-color: #999; }+/* Inline Lists */.inline-list { margin: 0 auto 1.0625em auto; margin-left: -1.375em; margin-right: 0; padding: 0; list-style: none; overflow: hidden; }.inline-list > li { list-style: none; float: left; margin-left: 1.375em; display: block; }diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.css b/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.cssindex 3742ed615d..bc997533d4 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.css+++ b/gitop.web/src/main/java/com/pmease/gitop/web/assets/css/page.css@@ -631,6 +631,31 @@ a.diffstat:hover { text-decoration: none; }.comment-list-header .checkbox { margin: 0; }.comment-list .form-comment { background: #f7f7f7; border: 1px solid #ddd; border-radius: 4px; padding-top: 8px; margin: 0; }+/**+ * BRANCHES PAGE+ */+.branches-page h2 { margin-top: 0;}+.table-branches td.actions { text-align: right; vertical-align: middle; }+.table-branches p { margin: 0;}+.table-branches td.meta a { font-size: 16px; font-weight: bold; }+.table-branches td.meta p { color: #666;}+.table-branches tr.default-branch { background: #333; color: white; }+.table-branches .default-branch .meta a { color: white; }+.table-branches .default-branch .meta p { color: #ccc; }++.bar { display: block; }+.statbar { position: relative; width: 220px; }+.statbar .ahead { position: absolute; left: 50%; right: 0; border-left: 1px solid #666; }+.statbar .behind { position: absolute; left: 0; right: 50%; border-right: 1px solid #666; }+.statbar .bar { height: 14px; }+.statbar .bar.bar-empty { min-width: 1px; background: #fff; }+.statbar .ahead .bar { background: #666; float: left; }+.statbar .behind .bar { background: #ccc; float: right; }+.statbar p { clear: both; margin: 0; color: #999; }+.statbar .ahead p { padding-left: 4px; }+.statbar .behind p { text-align: right; padding-right: 4px; }++/*** GATE KEEPER SETTING PAGE*/diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/component/BarLabel.java b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/component/BarLabel.javanew file mode 100644index 0000000000..27e9d27d3d--- /dev/null+++ b/gitop.web/src/main/java/com/pmease/gitop/web/common/wicket/component/BarLabel.java@@ -0,0 +1,59 @@+package com.pmease.gitop.web.common.wicket.component;++import java.util.Locale;++import org.apache.wicket.markup.ComponentTag;+import org.apache.wicket.markup.html.basic.Label;+import org.apache.wicket.model.IModel;+import org.apache.wicket.model.Model;++import com.google.common.base.Strings;+import com.pmease.gitop.web.common.datatype.DataTypes;++@SuppressWarnings("serial")+public class BarLabel extends Label {++ private final IModel<Double> percentModel;+ private final IModel<String> colorModel;++ public BarLabel(String id, IModel<Double> percentModel) {+ this(id, percentModel, Model.of(""));+ }++ public BarLabel(String id, IModel<Double> percentModel, IModel<String> colorModel) {+ super(id);++ this.percentModel = percentModel;+ this.colorModel = colorModel;+ }++ @Override+ protected void onComponentTag(final ComponentTag tag) {+ super.onComponentTag(tag);++ StringBuffer style = new StringBuffer();+ Double percent = percentModel.getObject();+ style.append("width: ")+ .append(DataTypes.PERCENT.asString(percent, "0.00000%", Locale.US));++ String color = colorModel.getObject();+ if (!Strings.isNullOrEmpty(color)) {+ style.append(";background:").append(color);+ }++ tag.put("style", style);+ }++ @Override+ public void onDetach() {+ if (percentModel != null) {+ percentModel.detach();+ }++ if (colorModel != null) {+ colorModel.detach();+ }++ super.onDetach();+ }+}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/git/command/AheadBehind.java b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/AheadBehind.javanew file mode 100644index 0000000000..3406ece678--- /dev/null+++ b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/AheadBehind.java@@ -0,0 +1,39 @@+package com.pmease.gitop.web.git.command;++import java.io.Serializable;++import com.google.common.base.Objects;+++@SuppressWarnings("serial")+public class AheadBehind implements Serializable {++ private int ahead;+ private int behind;++ public int getAhead() {+ return ahead;+ }++ public void setAhead(int ahead) {+ this.ahead = ahead;+ }++ public int getBehind() {+ return behind;+ }++ public void setBehind(int behind) {+ this.behind = behind;+ }++ @Override+ public String toString() {+ return "Ahead: " + ahead + ", behind: " + behind;+ }++ @Override+ public int hashCode() {+ return Objects.hashCode(ahead, behind);+ }+}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/git/command/AheadBehindCommand.java b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/AheadBehindCommand.javanew file mode 100644index 0000000000..c8b92a1ca0--- /dev/null+++ b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/AheadBehindCommand.java@@ -0,0 +1,71 @@+package com.pmease.gitop.web.git.command;++import java.io.File;+import java.util.Map;+import java.util.regex.Matcher;+import java.util.regex.Pattern;++import javax.annotation.Nullable;++import org.parboiled.common.Preconditions;++import com.pmease.commons.git.command.GitCommand;+import com.pmease.commons.util.execution.Commandline;+import com.pmease.commons.util.execution.LineConsumer;++public class AheadBehindCommand extends GitCommand<AheadBehind> {++ public AheadBehindCommand(File repoDir) {+ super(repoDir);+ }++ public AheadBehindCommand(File repoDir, @Nullable Map<String, String> environments) {+ super(repoDir, environments);+ }++ private String leftBranch;+ private String rightBranch;++ public AheadBehindCommand leftBranch(String leftBranch) {+ this.leftBranch = Preconditions.checkNotNull(leftBranch);+ return this;+ }++ public AheadBehindCommand rightBranch(String rightBranch) {+ this.rightBranch = Preconditions.checkNotNull(rightBranch);+ return this;+ }++ static final Pattern pLeftRight = Pattern.compile("(\\d+)\\s+(\\d+)");+ @Override+ public AheadBehind call() {+ Commandline cmd = cmd();+ cmd.addArgs("rev-list", "--left-right", "--count");+ cmd.addArgs(Preconditions.checkArgNotNull(leftBranch, "leftBranch")+ + "..." + Preconditions.checkArgNotNull(rightBranch, "rightBranch"));++ final AheadBehind counter = new AheadBehind();+ cmd.execute(new LineConsumer() {++ @Override+ public void consume(String line) {+ Matcher m = pLeftRight.matcher(line);+ if (m.find()) {+ counter.setAhead(Integer.valueOf(m.group(1)));+ counter.setBehind(Integer.valueOf(m.group(2)));+ }+ }++ }, new LineConsumer.ErrorLogger());++ return counter;+ }++ public static void main(String[] args) {+ String str = "68 4";+ Matcher m = pLeftRight.matcher(str);+ if (m.find()) {+ System.out.println(m.group(1) + "\t" + m.group(2));+ }+ }+}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/git/command/BranchForEachRefCommand.java b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/BranchForEachRefCommand.javanew file mode 100644index 0000000000..2182b16be4--- /dev/null+++ b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/BranchForEachRefCommand.java@@ -0,0 +1,125 @@+package com.pmease.gitop.web.git.command;++import java.io.File;+import java.util.Date;+import java.util.Map;++import com.google.common.base.Splitter;+import com.google.common.base.Strings;+import com.google.common.collect.Iterables;+import com.google.common.collect.Maps;+import com.pmease.commons.git.BriefCommit;+import com.pmease.commons.git.UserInfo;+import com.pmease.commons.util.execution.Commandline;++public class BranchForEachRefCommand extends ForEachRefCommand<Map<String, BriefCommit>, BranchForEachRefCommand> {++ public BranchForEachRefCommand(File repoDir) {+ super(repoDir);+ }++ private static final String DEFAULT_FORMAT =+ "%(refname:short)|" + // ref name+ "%(objectname)|" + // ref sha-1+ "%(committername)|%(committeremail)|%(committerdate:raw)|" + // committer part+ "%(authorname)|%(authoremail)|%(authordate:raw)" + // author part+ "%09%(contents:subject)"; // \tcommit subject++ @Override+ protected void applyArgs(Commandline cmd) {+ super.applyArgs(cmd);++ if (Strings.isNullOrEmpty(getSort())) {+ cmd.addArgs("--sort=-committerdate");+ }++ if (Strings.isNullOrEmpty(getFormat())) {+ cmd.addArgs("--format=" + DEFAULT_FORMAT);+ }++ if (getPatterns().length == 0) {+ cmd.addArgs("refs/heads/");+ }+ }++ @Override+ public BranchForEachRefCommand format(String format) {+ throw new UnsupportedOperationException();+ }++ @Override+ protected ForEachRefOutputHandler<Map<String, BriefCommit>> getOutputHandler() {+ return new BranchOutputHandler();+ }++ static class BranchOutputHandler extends ForEachRefOutputHandler<Map<String, BriefCommit>> {+ Map<String, BriefCommit> branches = Maps.newLinkedHashMap();++ @Override+ public Map<String, BriefCommit> getOutput() {+ return branches;+ }++ @Override+ public void consume(String line) {+ int pos = line.indexOf('\t');+ if (pos <= 0)+ return;++ String first = line.substring(0, pos);+ String subject = line.substring(pos + 1);+ String[] pieces = Iterables.toArray(Splitter.on('|').split(first), String.class);++ int i = 0;+ String refname = pieces[i++];+ String sha = pieces[i++];++ UserInfo committer = new UserInfo(pieces[i++], parseEmail(pieces[i++]), parseDate(pieces[i++]));+ UserInfo author = new UserInfo(pieces[i++], parseEmail(pieces[i++]), parseDate(pieces[i++]));++ BriefCommit commit = new BriefCommit(sha, committer, author, subject);+ branches.put(refname, commit);+ }+ }++ static String parseEmail(String mail) {+ if (mail.charAt(0) == '<')+ mail = mail.substring(1, mail.length() - 1);++ return mail;+ }++ static Date parseDate(String str) {+ String[] pieces = Iterables.toArray(Splitter.on(" ").split(str), String.class);+ long when = Long.valueOf(pieces[0]) * 1000;+ return new Date(when);+ }++ @Override+ protected BranchForEachRefCommand self() {+ return this;+ }++ public static void main(String[] args) {+ String line = "master|6c355beafdbd0a62add3a3d89825ca87cf8ecec0|Linus Torvalds|<[email protected]>|1372550568 -0700|Linus Torvalds|<[email protected]>|1372550568 -0700 Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc";+ int pos = line.indexOf('\t');+ if (pos <= 0)+ return;++ String first = line.substring(0, pos);+ String subject = line.substring(pos + 1);+ String[] pieces = Iterables.toArray(Splitter.on('|').split(first), String.class);++ int i = 0;+ String refname = pieces[i++];+ String sha = pieces[i++];++ UserInfo committer = new UserInfo(pieces[i++], parseEmail(pieces[i++]), parseDate(pieces[i++]));+ UserInfo author = new UserInfo(pieces[i++], parseEmail(pieces[i++]), parseDate(pieces[i++]));+ System.out.println(refname);+ System.out.println(sha);+ System.out.println(committer);+ System.out.println(author);+ System.out.println(subject);+ }+}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/git/command/ForEachRefCommand.java b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/ForEachRefCommand.javanew file mode 100644index 0000000000..9658f7734c--- /dev/null+++ b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/ForEachRefCommand.java@@ -0,0 +1,111 @@+package com.pmease.gitop.web.git.command;++import java.io.File;+import java.util.Map;++import com.google.common.base.Strings;+import com.google.common.collect.ImmutableList;+import com.google.common.collect.Iterables;+import com.pmease.commons.git.command.GitCommand;+import com.pmease.commons.util.execution.Commandline;+import com.pmease.commons.util.execution.LineConsumer;++public abstract class ForEachRefCommand<T, V extends ForEachRefCommand<T, V>> extends GitCommand<T> {++ private String format;+ private String[] patterns = new String[0];+ private int count;+ private String sort;++ public ForEachRefCommand(File repoDir) {+ super(repoDir);+ }++ public ForEachRefCommand(File repoDir, Map<String, String> environments) {+ super(repoDir, environments);+ }++ public V format(String format) {+ this.format = format;+ return self();+ }++ public V patterns(String value, String... values) {+ if (value == null) {+ this.patterns = new String[0];+ } else {+ this.patterns = Iterables.toArray(ImmutableList.<String>builder()+ .add(value)+ .add(values)+ .build(),+ String.class);+ }++ return self();+ }++ public V count(int count) {+ this.count = count;+ return self();+ }++ public V sort(String sort) {+ this.sort = sort;+ return self();+ }++ abstract protected V self();+ abstract protected ForEachRefOutputHandler<T> getOutputHandler();++ @Override+ public T call() {+ Commandline cmd = cmd();+ cmd.addArgs("for-each-ref");++ applyArgs(cmd);++ ForEachRefOutputHandler<T> outputHandler = getOutputHandler();+ cmd.execute(outputHandler, getErrorHandler());++ return outputHandler.getOutput();+ }++ protected LineConsumer getErrorHandler() {+ return new LineConsumer.ErrorLogger();+ }++ protected void applyArgs(Commandline cmd) {+ if (getCount() > 0) {+ cmd.addArgs("--count=" + String.valueOf(getCount()));+ }++ if (!Strings.isNullOrEmpty(getSort())) {+ cmd.addArgs("--sort=" + getSort());+ }++ if (!Strings.isNullOrEmpty(getFormat())) {+ cmd.addArgs("--format=" + getFormat());+ }++ for (String each : getPatterns()) {+ cmd.addArgs(each);+ }+ }++ public String getFormat() {+ return format;+ }++ public String[] getPatterns() {+ return patterns;+ }++ public int getCount() {+ return count;+ }++ public String getSort() {+ return sort;+ }++}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/git/command/ForEachRefOutputHandler.java b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/ForEachRefOutputHandler.javanew file mode 100644index 0000000000..007731ede0--- /dev/null+++ b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/ForEachRefOutputHandler.java@@ -0,0 +1,9 @@+package com.pmease.gitop.web.git.command;++import com.pmease.commons.util.execution.LineConsumer;++public abstract class ForEachRefOutputHandler<T> extends LineConsumer {++ abstract public T getOutput();++}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/branches/BranchesPage.html b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/branches/BranchesPage.htmlindex 18221e889d..357646d0ad 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/branches/BranchesPage.html+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/branches/BranchesPage.html@@ -1,5 +1,59 @@<html xmlns:wicket><wicket:extend>- <h1>Branches</h1>+ <div class="padder">+ <div class="page-heading">+ <h2>Branches</h2>+ </div>++ <wicket:container wicket:id="content"></wicket:container>+ </div>++ <wicket:fragment wicket:id="nobranch">+ <div class="alert alert-warning">There is no branches in this repository</div>+ </wicket:fragment>++ <wicket:fragment wicket:id="branchesFrag">+ <table class="table table-branches">+ <tr class="default-branch">+ <td class="meta">+ <wicket:container wicket:id="defaultMeta"></wicket:container>+ </td>+ <td class="">+ </td>+ <td class="actions">+ Default branch+ </td>+ </tr>+ <tr class="branch" wicket:id="branches">+ <td class="meta">+ <wicket:container wicket:id="meta"></wicket:container>+ </td>+ <td class="">+ <wicket:container wicket:id="statbar"></wicket:container>+ </td>+ <td class="actions">+ <button class="btn btn-default"><i class="icon icon-git-branch-compare"></i> Compare</button>+ </td>+ </tr>+ </table>+ </wicket:fragment>++ <wicket:fragment wicket:id="metaFrag">+ <a wicket:id="branchlink"><span wicket:id="name"></span></a>+ <p>Last updated <span class="age" wicket:id="updatedTime"></span> by <span wicket:id="author"></span></p>+ </wicket:fragment>++ <wicket:fragment wicket:id="statBarFrag">+ <div class="statbar">+ <div class="ahead">+ <span class="bar bar-ahead" wicket:id="aheadbar"></span>+ <p><span wicket:id="aheadnum"></span> ahead</p>+ </div>+ <div class="behind">+ <span class="bar bar-behind" wicket:id="behindbar"></span>+ <p><span wicket:id="behindnum"></span> behind</p>+ </div>+ </div>+ </wicket:fragment></wicket:extend></html>\ No newline at end of filediff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/branches/BranchesPage.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/branches/BranchesPage.javaindex f60457fa2d..8de830bc51 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/branches/BranchesPage.java+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/branches/BranchesPage.java@@ -1,14 +1,88 @@package com.pmease.gitop.web.page.project.source.branches;+import java.io.File;+import java.util.List;+import java.util.Map;+import java.util.Map.Entry;++import org.apache.wicket.markup.html.basic.Label;+import org.apache.wicket.markup.html.link.AbstractLink;+import org.apache.wicket.markup.html.link.BookmarkablePageLink;+import org.apache.wicket.markup.html.list.ListItem;+import org.apache.wicket.markup.html.list.ListView;+import org.apache.wicket.markup.html.panel.Fragment;+import org.apache.wicket.model.AbstractReadOnlyModel;+import org.apache.wicket.model.IModel;+import org.apache.wicket.model.LoadableDetachableModel;+import org.apache.wicket.model.Model;import org.apache.wicket.request.mapper.parameter.PageParameters;+import com.google.common.base.Objects;+import com.google.common.collect.Lists;+import com.google.common.collect.Maps;+import com.pmease.commons.git.BriefCommit;+import com.pmease.gitop.web.common.wicket.component.BarLabel;+import com.pmease.gitop.web.component.label.AgeLabel;+import com.pmease.gitop.web.component.link.GitPersonLink;+import com.pmease.gitop.web.component.link.GitPersonLink.Mode;+import com.pmease.gitop.web.git.GitUtils;+import com.pmease.gitop.web.git.command.AheadBehind;+import com.pmease.gitop.web.git.command.AheadBehindCommand;+import com.pmease.gitop.web.git.command.BranchForEachRefCommand;import com.pmease.gitop.web.page.project.ProjectCategoryPage;+import com.pmease.gitop.web.page.project.api.GitPerson;+import com.pmease.gitop.web.page.project.source.tree.SourceTreePage;@SuppressWarnings("serial")public class BranchesPage extends ProjectCategoryPage {+ private final IModel<String> defaultBranchModel;+ private final IModel<Map<String, BriefCommit>> branchesModel;+ private final IModel<Map<String, AheadBehind>> aheadBehindsModel;+public BranchesPage(PageParameters params) {super(params);++ defaultBranchModel = new LoadableDetachableModel<String>() {++ @Override+ protected String load() {+ return GitUtils.getDefaultBranch(getProject().code());+ }++ };++ branchesModel = new LoadableDetachableModel<Map<String, BriefCommit>>() {++ @Override+ protected Map<String, BriefCommit> load() {+ BranchForEachRefCommand cmd = new BranchForEachRefCommand(getProject().code().repoDir());+ return cmd.call();+ }+ };++ aheadBehindsModel = new LoadableDetachableModel<Map<String ,AheadBehind>>() {++ @Override+ protected Map<String, AheadBehind> load() {+ List<String> branchNames = getBranchNames();++ Map<String, AheadBehind> map = Maps.newHashMap();+ File repoDir = getProject().code().repoDir();+ String defaultBranch = getDefaultBranch();+ for (String each : branchNames) {+ if (Objects.equal(defaultBranch, each)) {+ map.put(each, new AheadBehind());+ } else {+ AheadBehindCommand command = new AheadBehindCommand(repoDir);+ AheadBehind ab = command.leftBranch(each).rightBranch(defaultBranch).call();+ map.put(each, ab);+ }+ }++ return map;+ }+ };}@Override@@ -16,4 +90,141 @@ public class BranchesPage extends ProjectCategoryPage {return getProject() + " - branches";}+ @Override+ protected void onPageInitialize() {+ super.onPageInitialize();++ if (getDefaultBranch() == null) {+ add(new Fragment("content", "nobranch", this));+ } else {+ Fragment frag = new Fragment("content", "branchesFrag", this);+ frag.add(new MetaFrag("defaultMeta", getDefaultBranch()));++ IModel<List<String>> names = new AbstractReadOnlyModel<List<String>>() {++ @Override+ public List<String> getObject() {+ Map<String, BriefCommit> branches = branchesModel.getObject();+ List<String> list = Lists.newArrayList();+ String defaultName = getDefaultBranch();+ for (String each : branches.keySet()) {+ if (!Objects.equal(each, defaultName)) {+ list.add(each);+ }+ }++ return list;+ }+ };++ frag.add(new ListView<String>("branches", names) {++ @Override+ protected void populateItem(ListItem<String> item) {+ String refName = item.getModelObject();++ item.add(new MetaFrag("meta", refName));+ AheadBehind ab = getAheadBehind(refName);++ Fragment barFrag = new Fragment("statbar", "statBarFrag", BranchesPage.this);+ item.add(barFrag);+ barFrag.add(new BarLabel("aheadbar", Model.of(getPercent(ab.getAhead(), true))));+ barFrag.add(new Label("aheadnum", ab.getAhead()));+ barFrag.add(new BarLabel("behindbar", Model.of(getPercent(ab.getBehind(), false))));+ barFrag.add(new Label("behindnum", ab.getBehind()));+ }+ });++ add(frag);+ }+ }++ private int getMax(boolean isAhead) {+ Map<String, AheadBehind> map = aheadBehindsModel.getObject();+ int max = 0;+ for (Entry<String, AheadBehind> entry : map.entrySet()) {+ max = Math.max(max, isAhead ? entry.getValue().getAhead() : entry.getValue().getBehind());+ }+ return max;+ }++ // in case the bar is empty when percent is zero, we give it a very small+ // width, so the bar can be displayed always+ //+ static final double MIN_SIZE = 0.0001;++ private Double getPercent(int value, boolean isAhead) {+ int max = getMax(isAhead);+ double percent = max == 0 ? 0d : new Double(value) / max * 0.9d;+ if (percent == 0d) {+ percent = MIN_SIZE;+ }++ return percent;+ }++ String getDefaultBranch() {+ return defaultBranchModel.getObject();+ }++ private List<String> getBranchNames() {+ return Lists.newArrayList(branchesModel.getObject().keySet());+ }++ class MetaFrag extends Fragment {+ private final String refName;++ public MetaFrag(String id, String refName) {+ super(id, "metaFrag", BranchesPage.this);+ this.refName = refName;+ }++ @Override+ protected void onInitialize() {+ super.onInitialize();++ AbstractLink link = new BookmarkablePageLink<Void>("branchlink",+ SourceTreePage.class,+ SourceTreePage.newParams(getProject(), refName));+ link.add(new Label("name", refName));+ add(link);++ BriefCommit commit = getLastCommit(refName);+ add(new AgeLabel("updatedTime", Model.of(commit.getAuthor().getDate())));+ add(new GitPersonLink("author",+ Model.<GitPerson>of(GitPerson.of(commit.getAuthor())),+ Mode.NAME_ONLY));+ }+ }++ BriefCommit getLastCommit(String refName) {+ Map<String, BriefCommit> branches = branchesModel.getObject();+ System.out.println(branches.keySet());+ if (branches.containsKey(refName))+ return branches.get(refName);+ else+ throw new IllegalStateException();+ }++ AheadBehind getAheadBehind(String refName) {+ Map<String, AheadBehind> map = aheadBehindsModel.getObject();+ return map.get(refName);+ }++ @Override+ public void onDetach() {+ if (branchesModel != null) {+ branchesModel.detach();+ }++ if (defaultBranchModel != null) {+ defaultBranchModel.detach();+ }++ if (aheadBehindsModel != null) {+ aheadBehindsModel.detach();+ }++ super.onDetach();+ }}diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/CommentListPanel.html b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/CommentListPanel.htmlindex b45553384a..87e207380c 100644--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/CommentListPanel.html+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/diff/CommentListPanel.html@@ -28,7 +28,7 @@</wicket:container></div>- <hr />+ <hr class="dash deep" /><div class="comment-holder media comment-form-container" wicket:id="formholder"><span class="pull-left comment-author">