Skip to content

The Unified and Autonomous Development Platform

mid work

robin shine602a85bdb8e2
diff --git a/commons.git/src/main/java/com/pmease/commons/git/BlobChange.java b/commons.git/src/main/java/com/pmease/commons/git/BlobChange.java
index 5fecd4b607..caa2dc4768 100644
--- a/commons.git/src/main/java/com/pmease/commons/git/BlobChange.java
+++ b/commons.git/src/main/java/com/pmease/commons/git/BlobChange.java
@@ -35,7 +35,7 @@ public abstract class BlobChange implements Serializable {
if (changeType != ChangeType.ADD) {
oldBlobIdent = new BlobIdent(oldCommitHash, diffEntry.getOldPath(), diffEntry.getOldMode().getBits());
AnyObjectId id = diffEntry.getOldId().toObjectId();
- newBlobIdent.id = id!=null?id.name():null;
+ oldBlobIdent.id = id!=null?id.name():null;
} else {
oldBlobIdent = new BlobIdent(oldCommitHash, null, null);
}
@@ -55,47 +55,51 @@ public abstract class BlobChange implements Serializable {
public List<DiffBlock> getDiffs() {
if (diffs == null) {
- if (changeType == ChangeType.ADD) {
- Blob newBlob = getBlob(newBlobIdent);
- if (newBlob.getText() != null) {
- List<String> newLines = newBlob.getText().getLines(getLineProcessor());
- if (newLines.size() <= DiffUtils.MAX_DIFF_LEN) {
- List<String> oldLines = new ArrayList<>();
- diffs = DiffUtils.diff(oldLines, null, newLines, newBlobIdent.getFileName());
+ try {
+ if (changeType == ChangeType.ADD) {
+ Blob newBlob = getBlob(newBlobIdent);
+ if (newBlob.getText() != null) {
+ List<String> newLines = newBlob.getText().getLines(getLineProcessor());
+ if (newLines.size() <= DiffUtils.MAX_DIFF_LEN) {
+ List<String> oldLines = new ArrayList<>();
+ diffs = DiffUtils.diff(oldLines, null, newLines, newBlobIdent.getFileName());
+ } else {
+ diffs = new ArrayList<>();
+ }
} else {
diffs = new ArrayList<>();
}
- } else {
- diffs = new ArrayList<>();
- }
- } else if (changeType == ChangeType.DELETE) {
- Blob oldBlob = getBlob(oldBlobIdent);
- if (oldBlob.getText() != null) {
- List<String> oldLines = oldBlob.getText().getLines(getLineProcessor());
- if (oldLines.size() <= DiffUtils.MAX_DIFF_LEN) {
- List<String> newLines = new ArrayList<>();
- diffs = DiffUtils.diff(oldLines, oldBlobIdent.getFileName(), newLines, null);
+ } else if (changeType == ChangeType.DELETE) {
+ Blob oldBlob = getBlob(oldBlobIdent);
+ if (oldBlob.getText() != null) {
+ List<String> oldLines = oldBlob.getText().getLines(getLineProcessor());
+ if (oldLines.size() <= DiffUtils.MAX_DIFF_LEN) {
+ List<String> newLines = new ArrayList<>();
+ diffs = DiffUtils.diff(oldLines, oldBlobIdent.getFileName(), newLines, null);
+ } else {
+ diffs = new ArrayList<>();
+ }
} else {
diffs = new ArrayList<>();
}
- } else {
+ } else if (oldBlobIdent.id != null && oldBlobIdent.id.equals(newBlobIdent.id)) {
diffs = new ArrayList<>();
- }
- } else if (oldBlobIdent.id != null && oldBlobIdent.id.equals(newBlobIdent.id)) {
- diffs = new ArrayList<>();
- } else {
- Blob oldBlob = getBlob(oldBlobIdent);
- Blob newBlob = getBlob(newBlobIdent);
- if (oldBlob.getText() != null && newBlob.getText() != null) {
- List<String> oldLines = oldBlob.getText().getLines(getLineProcessor());
- List<String> newLines = newBlob.getText().getLines(getLineProcessor());
- if (oldLines.size() + newLines.size() <= DiffUtils.MAX_DIFF_LEN)
- diffs = DiffUtils.diff(oldLines, oldBlobIdent.getFileName(), newLines, newBlobIdent.getFileName());
- else
- diffs = new ArrayList<>();
} else {
- diffs = new ArrayList<>();
+ Blob oldBlob = getBlob(oldBlobIdent);
+ Blob newBlob = getBlob(newBlobIdent);
+ if (oldBlob.getText() != null && newBlob.getText() != null) {
+ List<String> oldLines = oldBlob.getText().getLines(getLineProcessor());
+ List<String> newLines = newBlob.getText().getLines(getLineProcessor());
+ if (oldLines.size() + newLines.size() <= DiffUtils.MAX_DIFF_LEN)
+ diffs = DiffUtils.diff(oldLines, oldBlobIdent.getFileName(), newLines, newBlobIdent.getFileName());
+ else
+ diffs = new ArrayList<>();
+ } else {
+ diffs = new ArrayList<>();
+ }
}
+ } catch (Exception e) {
+ throw new RuntimeException("Error calculating diff of file: " + getPath(), e);
}
}
return diffs;
@@ -119,10 +123,6 @@ public abstract class BlobChange implements Serializable {
return deletions;
}
- public void setDiffs(List<DiffBlock> diffs) {
- this.diffs = diffs;
- }
-
public String getPath() {
return newBlobIdent.path != null? newBlobIdent.path: oldBlobIdent.path;
}
diff --git a/commons.lang/src/main/java/com/pmease/commons/lang/extractors/java/JavaExtractor.java b/commons.lang/src/main/java/com/pmease/commons/lang/extractors/java/JavaExtractor.java
index dd479a1384..9baa6a5a84 100644
--- a/commons.lang/src/main/java/com/pmease/commons/lang/extractors/java/JavaExtractor.java
+++ b/commons.lang/src/main/java/com/pmease/commons/lang/extractors/java/JavaExtractor.java
@@ -1,39 +1,6 @@
package com.pmease.commons.lang.extractors.java;
-import static com.pmease.commons.lang.java.JavaLexer.ASSIGN;
-import static com.pmease.commons.lang.java.JavaLexer.AT;
-import static com.pmease.commons.lang.java.JavaLexer.BOOLEAN;
-import static com.pmease.commons.lang.java.JavaLexer.BYTE;
-import static com.pmease.commons.lang.java.JavaLexer.CHAR;
-import static com.pmease.commons.lang.java.JavaLexer.CLASS;
-import static com.pmease.commons.lang.java.JavaLexer.COMMA;
-import static com.pmease.commons.lang.java.JavaLexer.DEFAULT;
-import static com.pmease.commons.lang.java.JavaLexer.DOT;
-import static com.pmease.commons.lang.java.JavaLexer.DOUBLE;
-import static com.pmease.commons.lang.java.JavaLexer.ELLIPSIS;
-import static com.pmease.commons.lang.java.JavaLexer.ENUM;
-import static com.pmease.commons.lang.java.JavaLexer.FLOAT;
-import static com.pmease.commons.lang.java.JavaLexer.GT;
-import static com.pmease.commons.lang.java.JavaLexer.IMPORT;
-import static com.pmease.commons.lang.java.JavaLexer.INT;
-import static com.pmease.commons.lang.java.JavaLexer.INTERFACE;
-import static com.pmease.commons.lang.java.JavaLexer.Identifier;
-import static com.pmease.commons.lang.java.JavaLexer.LBRACE;
-import static com.pmease.commons.lang.java.JavaLexer.LBRACK;
-import static com.pmease.commons.lang.java.JavaLexer.LONG;
-import static com.pmease.commons.lang.java.JavaLexer.LPAREN;
-import static com.pmease.commons.lang.java.JavaLexer.LT;
-import static com.pmease.commons.lang.java.JavaLexer.PACKAGE;
-import static com.pmease.commons.lang.java.JavaLexer.RBRACE;
-import static com.pmease.commons.lang.java.JavaLexer.RBRACK;
-import static com.pmease.commons.lang.java.JavaLexer.RPAREN;
-import static com.pmease.commons.lang.java.JavaLexer.SEMI;
-import static com.pmease.commons.lang.java.JavaLexer.SHORT;
-import static com.pmease.commons.lang.java.JavaLexer.STATIC;
-import static com.pmease.commons.lang.java.JavaLexer.StringLiteral;
-import static com.pmease.commons.lang.java.JavaLexer.THIS;
-import static com.pmease.commons.lang.java.JavaLexer.THROWS;
-import static com.pmease.commons.lang.java.JavaLexer.VOID;
+import static com.pmease.commons.lang.extractors.java.JavaLexer.*;
import java.util.ArrayList;
import java.util.List;
@@ -51,7 +18,7 @@ import com.pmease.commons.lang.extractors.ExtractToken;
import com.pmease.commons.lang.extractors.Symbol;
import com.pmease.commons.lang.extractors.TokenFilter;
import com.pmease.commons.lang.extractors.TokenPosition;
-import com.pmease.commons.lang.java.JavaLexer;
+import com.pmease.commons.lang.extractors.java.JavaLexer;
import com.pmease.commons.util.Pair;
public class JavaExtractor extends AbstractExtractor {
diff --git a/commons.lang/src/test/java/com/pmease/commons/lang/extractors/java/ExtractStreamTest.java b/commons.lang/src/test/java/com/pmease/commons/lang/extractors/java/ExtractStreamTest.java
index 2b25f0fb59..785442ee61 100644
--- a/commons.lang/src/test/java/com/pmease/commons/lang/extractors/java/ExtractStreamTest.java
+++ b/commons.lang/src/test/java/com/pmease/commons/lang/extractors/java/ExtractStreamTest.java
@@ -9,7 +9,7 @@ import org.junit.Test;
import com.pmease.commons.lang.extractors.ExtractStream;
import com.pmease.commons.lang.extractors.TokenFilter;
import com.pmease.commons.lang.extractors.UnexpectedTokenException;
-import com.pmease.commons.lang.java.JavaLexer;
+import com.pmease.commons.lang.extractors.java.JavaLexer;
public class ExtractStreamTest {
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/CommonPage.java b/commons.wicket/src/main/java/com/pmease/commons/wicket/CommonPage.java
index 930c7b98da..23c996464e 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/CommonPage.java
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/CommonPage.java
@@ -118,20 +118,12 @@ public abstract class CommonPage extends WebPage {
public void pushState(AjaxRequestTarget target, String url, Serializable data) {
String encodedData = new String(Base64.encodeBase64(SerializationUtils.serialize(data)));
- target.prependJavaScript(String.format(""
- + "var state = {data:'%s'};"
- + "pmease.commons.history.current = {state: state, url: '%s'};"
- + "history.pushState(state, '', '%s');",
- encodedData, url, url));
+ target.prependJavaScript(String.format("pmease.commons.history.pushState('%s', '%s');", encodedData, url));
}
public void replaceState(AjaxRequestTarget target, String url, Serializable data) {
String encodedData = new String(Base64.encodeBase64(SerializationUtils.serialize(data)));
- target.prependJavaScript(String.format(""
- + "var state = {data:'%s'};"
- + "pmease.commons.history.current = {state: state, url: '%s'};"
- + "history.replaceState(state, '', '%s');",
- encodedData, url, url));
+ target.prependJavaScript(String.format("pmease.commons.history.replaceState('%s', '%s');", encodedData, url));
}
@Override
diff --git a/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/common.js b/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/common.js
index 594516ad93..c20585c644 100644
--- a/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/common.js
+++ b/commons.wicket/src/main/java/com/pmease/commons/wicket/assets/common.js
@@ -831,24 +831,30 @@ pmease.commons = {
history: {
init: function(callback) {
+ pmease.commons.history.urlWithoutHash = location.pathname+(location.search?location.search:"");
+
// Use a timeout here solve the problem that Safari (and previous versions of Chrome)
// fires event "onpopstate" on initial page load and this causes the page to reload
// infinitely
setTimeout(function() {
window.onpopstate = function(event) {
- if (pmease.commons.form.confirmLeave()) {
- if (!event.state || !event.state.data)
- location.reload();
- else
- callback(event.state.data);
- pmease.commons.history.current = {
- state: event.state,
- url: window.location.href
- };
- } else {
- history.pushState(pmease.commons.history.current.state, '' ,
- pmease.commons.history.current.url);
+ var currentUrlWithoutHash = location.pathname+(location.search?location.search:"");
+ if (currentUrlWithoutHash != pmease.commons.history.urlWithoutHash) { // ignore hash changes
+ if (pmease.commons.form.confirmLeave()) {
+ if (!event.state || !event.state.data)
+ location.reload();
+ else
+ callback(event.state.data);
+ pmease.commons.history.current = {
+ state: event.state,
+ url: window.location.href
+ };
+ } else {
+ history.pushState(pmease.commons.history.current.state, '' ,
+ pmease.commons.history.current.url);
+ }
}
+ pmease.commons.history.urlWithoutHash = currentUrlWithoutHash;
};
}, 100);
@@ -856,6 +862,18 @@ pmease.commons = {
url: window.location.href
};
},
+ pushState: function(data, url) {
+ var state = {data: data};
+ pmease.commons.history.current = {state: state, url: url};
+ history.pushState(state, '', url);
+ pmease.commons.history.urlWithoutHash = location.pathname+(location.search?location.search:'');
+ },
+ replaceState: function(data, url) {
+ var state = {data: data};
+ pmease.commons.history.current = {state: state, url: url};
+ history.replaceState(state, '', url);
+ pmease.commons.history.urlWithoutHash = location.pathname+(location.search?location.search:'');
+ },
setScrollPos: function(scrollPos) {
var state = history.state;
if (!state)
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/hookcallback/GitPostReceiveCallback.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/hookcallback/GitPostReceiveCallback.java
index e0c1f541b1..e4ae8bfcfe 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/hookcallback/GitPostReceiveCallback.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/hookcallback/GitPostReceiveCallback.java
@@ -82,10 +82,12 @@ public class GitPostReceiveCallback extends HttpServlet {
String field = fields.get(pos);
// String oldCommitHash = StringUtils.reverse(field.substring(0, 40));
- if (!newCommitHash.equals(GitUtils.NULL_SHA1))
+ if (!newCommitHash.equals(GitUtils.NULL_SHA1)) {
repository.cacheObjectId(refName, ObjectId.fromString(newCommitHash));
- else
+ } else {
+ newCommitHash = null;
repository.cacheObjectId(refName, null);
+ }
for (RepositoryListener listener: listenersProvider.get())
listener.onRefUpdate(repository, refName, newCommitHash);
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/listeners/RepositoryListener.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/listeners/RepositoryListener.java
index 811f4560a4..a8e501c9e6 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/listeners/RepositoryListener.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/listeners/RepositoryListener.java
@@ -12,5 +12,15 @@ public interface RepositoryListener {
void afterDelete(Repository repository);
+ /**
+ * Update or delete a ref
+ *
+ * @param repository
+ * repository to update/delete ref inside
+ * @param refName
+ * name of the ref to update/delete
+ * @param newCommitHash
+ * new commit hash of the ref, or <tt>null</tt> if delete a ref
+ */
void onRefUpdate(Repository repository, String refName, @Nullable String newCommitHash);
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffstat/DiffStatBar.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffstat/DiffStatBar.html
index c11f55d669..3fd94e1570 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffstat/DiffStatBar.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffstat/DiffStatBar.html
@@ -1,6 +1,6 @@
<html xmlns:wicket>
<wicket:panel>
- <span class="diff-stat">
+ <span class="diff-stat-bar">
<i class="additions" wicket:id="additions"></i><i class="deletions" wicket:id="deletions"></i><i wicket:id="spacer"></i>
</span>
</wicket:panel>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffstat/DiffStatBar.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffstat/DiffStatBar.java
index 4bb76d34fa..0b3710b152 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffstat/DiffStatBar.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffstat/DiffStatBar.java
@@ -16,7 +16,7 @@ import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig
@SuppressWarnings("serial")
public class DiffStatBar extends Panel {
- private static final int MAX_BLOCKS = 8;
+ private static final int MAX_BLOCKS = 5;
private final int additions;
@@ -40,9 +40,8 @@ public class DiffStatBar extends Panel {
@Override
public String getObject() {
- int i = getAdditionBlocks();
StringBuffer sb = new StringBuffer();
- while (i-- > 0)
+ for (int i=0; i<getAdditionBlocks(); i++)
sb.append("&#xf0c8; ");
return sb.toString();
}
@@ -53,12 +52,9 @@ public class DiffStatBar extends Panel {
@Override
public String getObject() {
- int i = getDeletionBlocks();
-
StringBuffer sb = new StringBuffer();
- while (i-- > 0) {
+ for (int i=0; i<getDeletionBlocks(); i++)
sb.append("&#xf0c8; ");
- }
return sb.toString();
}
}).setEscapeModelStrings(false));
@@ -67,10 +63,8 @@ public class DiffStatBar extends Panel {
@Override
public String getObject() {
- int i = MAX_BLOCKS + 1 - getAdditionBlocks() - getDeletionBlocks();
-
StringBuffer sb = new StringBuffer();
- while (i-- > 0)
+ for (int i=0; i<MAX_BLOCKS - getAdditionBlocks() - getDeletionBlocks(); i++)
sb.append("&#xf0c8; ");
return sb.toString();
@@ -115,7 +109,7 @@ public class DiffStatBar extends Panel {
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
- response.render(CssHeaderItem.forReference(new CssResourceReference(DiffStatBar.class, "diff-stat.css")));
+ response.render(CssHeaderItem.forReference(new CssResourceReference(DiffStatBar.class, "diff-stat-bar.css")));
}
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffstat/diff-stat.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffstat/diff-stat-bar.css
similarity index 54%
rename from gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffstat/diff-stat.css
rename to gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffstat/diff-stat-bar.css
index 250d5ff6a6..2baf4f0443 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffstat/diff-stat.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/diffstat/diff-stat-bar.css
@@ -1,15 +1,16 @@
-.diff-stat {
+.diff-stat-bar {
font-family: 'FontAwesome';
color: #ddd;
}
-.diff-stat>i {
+.diff-stat-bar>i {
+ font-size: 10px;
font-style: normal;
word-spacing: -2px;
}
-.diff-stat .additions {
+.diff-stat-bar .additions {
color: #35c335;
}
-.diff-stat .deletions {
+.diff-stat-bar .deletions {
color: #c33535;
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html
index 95261ce646..f8822f7389 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.html
@@ -17,16 +17,18 @@
<div wicket:id="tooManyChanges" class="alert alert-warning">
Sorry we can not display the full diff as there are too many changes
</div>
- <ul class="diff-stats">
+ <ul class="diff-stats list-unstyled">
<li wicket:id="diffStats" class="diff-stat clearfix">
<i wicket:id="icon" class="icon pull-left"></i>
<a wicket:id="path" class="path pull-left"><span wicket:id="path"></span></a>
+ <wicket:enclosure child="bar">
<span wicket:id="bar" class="bar pull-right"></span>
<span wicket:id="deletions" class="deletions pull-right"></span>
<span wicket:id="additions" class="additions pull-right"></span>
+ </wicket:enclosure>
</li>
</ul>
- <ul class="changes">
+ <ul class="changes list-unstyled">
<li wicket:id="changes" class="change">
<div wicket:id="change"></div>
</li>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java
index 6cb64a8b12..19769c13ca 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java
@@ -6,7 +6,9 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.Future;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -90,19 +92,13 @@ public class RevisionDiffPanel extends Panel {
}
}
+ System.out.println("**************************");
+
// Diff calculation can be slow, so we pre-load diffs of each change
// concurrently
+ long time = System.currentTimeMillis();
Collection<Callable<Void>> tasks = new ArrayList<>();
for (final BlobChange change: changes) {
- // to avoid race conditions during concurrent diff calculation, we
- // pre-populate blob data in repository
- /*
- if (change.getOldBlobIdent().path != null)
- repoModel.getObject().getBlob(change.getOldBlobIdent());
- if (change.getNewBlobIdent().path != null)
- repoModel.getObject().getBlob(change.getNewBlobIdent());
- */
-
tasks.add(new Callable<Void>() {
@Override
@@ -113,8 +109,15 @@ public class RevisionDiffPanel extends Panel {
});
}
-
- GitPlex.getInstance(ForkJoinPool.class).invokeAll(tasks);
+ for (Future<Void> future: GitPlex.getInstance(ForkJoinPool.class).invokeAll(tasks)) {
+ try {
+ // call get in order to throw exception if there is any during task execution
+ future.get();
+ } catch (InterruptedException|ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ System.out.println(System.currentTimeMillis()-time);
if (changes.size() == entries.size()) {
// some changes should be removed if content is the same after line processing
@@ -171,14 +174,14 @@ public class RevisionDiffPanel extends Panel {
}));
- add(new Label("totalAdditions", new LoadableDetachableModel<Integer>() {
+ add(new Label("totalAdditions", new LoadableDetachableModel<String>() {
@Override
- protected Integer load() {
+ protected String load() {
int totalAdditions = 0;
for (BlobChange change: getChanges())
totalAdditions += change.getAdditions();
- return totalAdditions;
+ return totalAdditions + " additions";
}
}) {
@@ -191,14 +194,14 @@ public class RevisionDiffPanel extends Panel {
});
- add(new Label("totalDeletions", new LoadableDetachableModel<Integer>() {
+ add(new Label("totalDeletions", new LoadableDetachableModel<String>() {
@Override
- protected Integer load() {
+ protected String load() {
int totalDeletions = 0;
for (BlobChange change: getChanges())
totalDeletions += change.getDeletions();
- return totalDeletions;
+ return totalDeletions + " deletions";
}
}) {
@@ -297,9 +300,23 @@ public class RevisionDiffPanel extends Panel {
item.add(pathLink);
- item.add(new Label("additions", change.getAdditions()));
- item.add(new Label("deletions", change.getDeletions()));
- item.add(new DiffStatBar("bar", change.getAdditions(), change.getDeletions(), false));
+ item.add(new Label("additions", "+" + change.getAdditions()));
+ item.add(new Label("deletions", "-" + change.getDeletions()));
+
+ boolean barVisible;
+ if (change.getChangeType() == ChangeType.ADD) {
+ Blob.Text text = repoModel.getObject().getBlob(change.getNewBlobIdent()).getText();
+ barVisible = (text != null && text.getLines().size() <= DiffUtils.MAX_DIFF_LEN);
+ } else if (change.getChangeType() == ChangeType.DELETE) {
+ Blob.Text text = repoModel.getObject().getBlob(change.getOldBlobIdent()).getText();
+ barVisible = (text != null && text.getLines().size() <= DiffUtils.MAX_DIFF_LEN);
+ } else {
+ Blob.Text oldText = repoModel.getObject().getBlob(change.getOldBlobIdent()).getText();
+ Blob.Text newText = repoModel.getObject().getBlob(change.getNewBlobIdent()).getText();
+ barVisible = (oldText != null && newText != null
+ && oldText.getLines().size()+newText.getLines().size() <= DiffUtils.MAX_DIFF_LEN);
+ }
+ item.add(new DiffStatBar("bar", change.getAdditions(), change.getDeletions(), false).setVisible(barVisible));
}
});
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css
index e69de29bb2..7cc1d7eaa3 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/revision-diff.css
@@ -0,0 +1,49 @@
+.revision-diff>.head {
+ margin: 16px 0;
+}
+.revision-diff>.alert {
+ margin-bottom: 16px;
+}
+.revision-diff>.head>.title {
+ font-size: 15px;
+}
+.revision-diff>.head>.title .fa {
+ color: #BBB;
+}
+.revision-diff li.diff-stat {
+ font-size: 13px;
+}
+.revision-diff li.diff-stat>.icon {
+ margin-top: 2px;
+}
+.revision-diff .fa-diff-modified {
+ color: #D0B44C;
+}
+.revision-diff .fa-diff-added {
+ color: #35C335;
+}
+.revision-diff .fa-diff-removed {
+ color: #C33535;
+}
+.revision-diff .diff-stats li {
+ padding: 6px 0;
+ border-bottom: 1px solid #F2F2F2;
+}
+.revision-diff .diff-stats li:last-child {
+ border-bottom: none;
+}
+.revision-diff .diff-stats li a.path {
+ padding: 0 6px;
+}
+.revision-diff .diff-stats li>.additions {
+ color: #35C335;
+}
+.revision-diff .diff-stats li>.deletions {
+ color: #C33535;
+}
+.revision-diff .diff-stats li>.additions, .revision-diff .diff-stats li>.deletions {
+ font-size: 12px;
+ font-weight: bold;
+ margin-right: 4px;
+ margin-top: 2px;
+}
\ No newline at end of file