Skip to content

The Unified and Autonomous Development Platform

Refine commit page

steve0a0193d34eb0
diff --git a/gitop.web/pom.xml b/gitop.web/pom.xml
index 30136e06f3..6739f29f8c 100644
--- a/gitop.web/pom.xml
+++ b/gitop.web/pom.xml
@@ -112,6 +112,12 @@
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.8</version>
+ <exclusions>
+ <exclusion>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
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.css
index 96b1666e4e..4a1ec4a61c 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
@@ -362,7 +362,6 @@ ul.repo-actions { margin: 8px 4px 8px 0; padding: 0; list-style: none; }
.source-tree .last-commit { background: #f2f2f2; border-radius: 4px 4px 0 0; }
.source-tree .commit-message { padding: 8px 15px; }
-.commit-message > pre { }
.commit-message .title-message { display: inline-block; margin-right: 6px; background: transparent; border: none; margin: 0; padding: 0;}
.commit-message .detailed-message {font-size: 12px; color: #666; background: white; margin-top: 8px; }
@@ -447,9 +446,8 @@ table.table-blob { width: 100%; }
.commit-group .commit-meta { margin-left: 64px; padding: 0; margin-right: 120px; background: transparent; border: none; }
.committer-info .icon { color: #999; font-size: 12px; }
.commit-group .commitish { width: 100px; overflow: hidden; }
-.commitish a { display: block; color: #888; font-size: 12px; }
-.commitish .browse-link { text-align: right; margin-top: 4px; }
-.commitish a.browse-link:hover { color: #09f; }
+.commit-group .commitish a { display: block; color: #888; font-size: 12px; text-align: right; margin-bottom: 4px;}
+.commit-group .commitish a:hover { color: #09f; }
.commit-group .detailed-toggle { cursor: pointer; }
.commit-group .detailed-toggle.collapsed .icon-toggle:before { content: "\F02B"; }
@@ -465,9 +463,10 @@ table.table-blob { width: 100%; }
.commit .author-info, .commit .committer-info { color: #999; margin: 0; }
.commit .author-info .name,
.commit .committer-info .name { font-weight: bold; color: #555; }
+.commit-head .piped li { border-color: #ddd; }
.commit .commit-message { border-bottom: 1px solid #ddd; margin-bottom: 9px; }
-.commit .detailed-message { color: #666; border-width: 0 0 0 1px; background: transparent; border-width: 0; padding: 0; }
+.commit .commit-message .detailed-message { color: #666; border-width: 0 0 0 1px; background: transparent; border-width: 0; padding: 0; font-size: 14px; }
#diff-toc .btn { float: right; }
#diff-toc.open .btn-show,
@@ -510,6 +509,7 @@ a.diffstat:hover { text-decoration: none; }
.diff-line-nums > .oldnum { border-right: 1px solid #ddd;}
.diff-line-nums > .expander { text-align: center; }
.diff-line-nums > .expander a { color: #999; display: block; }
+.diff-line-nums > .expander .icon { vertical-align: middle; }
.diff-line-nums > .expander a:hover { color: #333; text-decoration: none; }
.diff-line-nums > .expander em .icon:before { content: ' '; } /* disabled expander */
@@ -517,10 +517,13 @@ a.diffstat:hover { text-decoration: none; }
.diff-line.old { background: #fdd; }
.diff-line.new { background: #cfc; }
+.diff-line.new .diff-line-nums { background: #afa; }
+.diff-line.old .diff-line-nums { background: #faa; }
.diff-line.old .diff-line-nums > .oldnum { color: #8f0000; }
.diff-line.new .diff-line-nums > .newnum { color: #008f00; }
.diff-line:hover, .diff-line.hunk-head:hover { background: #fea; }
+.diff-line:hover .diff-line-nums { background: #ffe066; }
.diff-line .diff-line-code { margin-left: 110px; padding: 0 12px; }
.diff-line .diff-line-code pre { background: transparent; margin: 0; padding: 0; word-break: normal; word-wrap: normal; border: none; font-size: 12px; line-height: 20px; white-space: pre; }
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/git/command/AbstractDiffCommand.java b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/AbstractDiffCommand.java
index c777f8b2e5..a1fc3e118d 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/git/command/AbstractDiffCommand.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/AbstractDiffCommand.java
@@ -10,7 +10,7 @@ import com.pmease.commons.git.command.GitCommand;
import com.pmease.commons.loader.AppLoader;
import com.pmease.commons.util.execution.Commandline;
-public abstract class AbstractDiffCommand<T> extends GitCommand<T> {
+public abstract class AbstractDiffCommand<T, S extends AbstractDiffCommand<T, S>> extends GitCommand<T> {
public static enum RenameType {
NONE, FIND_RENAMES, FIND_COPIES, FIND_COPIES_HEADER
@@ -53,85 +53,93 @@ public abstract class AbstractDiffCommand<T> extends GitCommand<T> {
protected DiffAlgorithm diffAlgorithm = DiffAlgorithm.MYERS; // git default
+ protected String format;
public AbstractDiffCommand(File repoDir) {
super(repoDir);
}
- public AbstractDiffCommand<T> revision(String rev) {
+ protected abstract S self();
+
+ public S revision(String rev) {
this.rev = rev;
- return this;
+ return self();
}
- public AbstractDiffCommand<T> path(String path) {
+ public S path(String path) {
this.paths.add(path);
- return this;
+ return self();
}
- public AbstractDiffCommand<T> paths(List<String> paths) {
+ public S paths(List<String> paths) {
this.paths.addAll(paths);
- return this;
+ return self();
}
- public AbstractDiffCommand<T> contextLines(int contextLines) {
+ public S contextLines(int contextLines) {
this.contextLines = contextLines;
- return this;
+ return self();
}
- public AbstractDiffCommand<T> findCopiesHarder(boolean b) {
+ public S findCopiesHarder(boolean b) {
return renameType(b ? RenameType.FIND_COPIES_HEADER : RenameType.NONE);
}
- public AbstractDiffCommand<T> findCopies(boolean b) {
+ public S findCopies(boolean b) {
return findCopies(b, -1);
}
- public AbstractDiffCommand<T> findCopies(boolean b, int threshold) {
+ public S findCopies(boolean b, int threshold) {
return renameType(b ? RenameType.FIND_COPIES : RenameType.NONE, threshold);
}
- public AbstractDiffCommand<T> findRenames(boolean b) {
+ public S findRenames(boolean b) {
return findRenames(b, -1);
}
- public AbstractDiffCommand<T> findRenames(boolean b, int threshold) {
+ public S findRenames(boolean b, int threshold) {
return renameType(b ? RenameType.FIND_RENAMES : RenameType.NONE, threshold);
}
- private AbstractDiffCommand<T> renameType(RenameType renameType) {
+ private S renameType(RenameType renameType) {
return renameType(renameType, -1);
}
- private AbstractDiffCommand<T> renameType(RenameType renameType, int threshold) {
+ private S renameType(RenameType renameType, int threshold) {
this.renameType = renameType;
this.threshold = threshold;
- return this;
+ return self();
}
- private AbstractDiffCommand<T> whitespaceType(WhitespaceType whitespaceType) {
+ private S whitespaceType(WhitespaceType whitespaceType) {
this.whitespaceType = whitespaceType;
- return this;
+ return self();
}
- public AbstractDiffCommand<T> ignoreSpaceAtEol() {
+ public S ignoreSpaceAtEol() {
return whitespaceType(WhitespaceType.IGNORE_SPACE_AT_EOL);
}
- public AbstractDiffCommand<T> ignoreAllSpace() {
+ public S ignoreAllSpace() {
return whitespaceType(WhitespaceType.IGNORE_ALL_SPACE);
}
- public AbstractDiffCommand<T> ignoreBlankLines() {
+ public S ignoreBlankLines() {
return whitespaceType(WhitespaceType.IGNORE_BLANK_LINES);
}
- public AbstractDiffCommand<T> ignoreSpaceChange() {
+ public S ignoreSpaceChange() {
return whitespaceType(WhitespaceType.IGNORE_SPACE_CHANGE);
}
- public AbstractDiffCommand<T> diffAlgorithm(DiffAlgorithm algorithm) {
+ public S diffAlgorithm(DiffAlgorithm algorithm) {
this.diffAlgorithm = algorithm;
- return this;
+ return self();
+ }
+
+ public S format(String format) {
+ this.format = format;
+ return self();
}
@Override
@@ -154,23 +162,29 @@ public abstract class AbstractDiffCommand<T> extends GitCommand<T> {
protected Commandline buildCommand() {
Commandline cmd = newCommand();
- applyContextLines(cmd);
- applyWhitespaceType(cmd);
- applyRenameType(cmd);
- applyDiffAlgorithm(cmd);
+ addArgContextLines(cmd);
+ addArgWhitespaceType(cmd);
+ addArgRenameType(cmd);
+ addArgDiffAlgorithm(cmd);
- applyPaths(cmd);
+ addArgPaths(cmd);
return cmd;
}
- protected void applyContextLines(Commandline cmd) {
+ protected void applyFormat(Commandline cmd) {
+ if (!Strings.isNullOrEmpty(format)) {
+ cmd.addArgs("--format=", format);
+ }
+ }
+
+ protected void addArgContextLines(Commandline cmd) {
if (contextLines > 0) {
cmd.addArgs("-U" + contextLines);
}
}
- protected void applyPaths(Commandline cmd) {
+ protected void addArgPaths(Commandline cmd) {
if (paths.isEmpty())
return;
@@ -182,7 +196,7 @@ public abstract class AbstractDiffCommand<T> extends GitCommand<T> {
}
}
- protected void applyWhitespaceType(Commandline cmd) {
+ protected void addArgWhitespaceType(Commandline cmd) {
switch (whitespaceType) {
case IGNORE_SPACE_AT_EOL:
cmd.addArgs("--ignore-space-at-eol");
@@ -205,7 +219,7 @@ public abstract class AbstractDiffCommand<T> extends GitCommand<T> {
}
}
- protected void applyRenameType(Commandline cmd) {
+ protected void addArgRenameType(Commandline cmd) {
if (renameType == RenameType.FIND_COPIES_HEADER) {
cmd.addArgs("--find-copies-harder");
} else if (renameType == RenameType.FIND_COPIES) {
@@ -215,7 +229,7 @@ public abstract class AbstractDiffCommand<T> extends GitCommand<T> {
}
}
- protected void applyDiffAlgorithm(Commandline cmd) {
+ protected void addArgDiffAlgorithm(Commandline cmd) {
if (diffAlgorithm != DiffAlgorithm.MYERS) {
cmd.addArgs("--" + diffAlgorithm.name().toLowerCase());
}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/git/command/DiffTreeCommand.java b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/DiffTreeCommand.java
index 68f3df1260..c0541d5937 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/git/command/DiffTreeCommand.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/git/command/DiffTreeCommand.java
@@ -13,9 +13,10 @@ import com.google.common.io.ByteStreams;
import com.pmease.commons.util.execution.Commandline;
import com.pmease.gitop.web.page.project.source.commit.patch.Patch;
-public class DiffTreeCommand extends AbstractDiffCommand<Patch> {
+public class DiffTreeCommand extends AbstractDiffCommand<Patch, DiffTreeCommand> {
- boolean recurse;
+ boolean recurse = true;
+ private boolean root = true;
public DiffTreeCommand(File repoDir) {
super(repoDir);
@@ -24,18 +25,22 @@ public class DiffTreeCommand extends AbstractDiffCommand<Patch> {
@Override
protected Commandline newCommand() {
Commandline cmd = super.newCommand();
- cmd.addArgs("--root");
- cmd.addArgs("--no-commit-id");
+
+ if (root) {
+ cmd.addArgs("--root");
+ }
if (recurse) {
cmd.addArgs("-r");
}
+ cmd.addArgs("--no-commit-id");
+
return cmd;
}
@Override
- protected void applyPaths(Commandline cmd) {
+ protected void addArgPaths(Commandline cmd) {
cmd.addArgs("--");
for (String path : paths) {
if (!Strings.isNullOrEmpty(path)) {
@@ -46,7 +51,12 @@ public class DiffTreeCommand extends AbstractDiffCommand<Patch> {
public DiffTreeCommand recurse(boolean recurse) {
this.recurse = recurse;
- return this;
+ return self();
+ }
+
+ public DiffTreeCommand root(boolean root) {
+ this.root = root;
+ return self();
}
@Override
@@ -75,4 +85,9 @@ public class DiffTreeCommand extends AbstractDiffCommand<Patch> {
protected String getSubCommand() {
return "diff-tree";
}
+
+ @Override
+ protected DiffTreeCommand self() {
+ return this;
+ }
}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/SourceCommitPage.html b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/SourceCommitPage.html
index 18131d5922..5a979f0887 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/SourceCommitPage.html
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/SourceCommitPage.html
@@ -15,14 +15,17 @@
<ul class="piped">
<li><span class="sha" wicket:id="commitsha"></span></li>
- <li>parents
+ <li><wicket:container wicket:id="parentslabel"></wicket:container>
<wicket:container wicket:id="parents">
<span wicket:id="connector">+</span>
<a class="sha" wicket:id="link"><span wicket:id="sha"></span></a>
</wicket:container>
</li>
</ul>
-
+ <div class="branches" style="padding-top: 5px; margin-top: 5px; border-top: 1px solid #e5e5e5;">
+ <i class="icon icon-git-branch"></i>
+ </div>
+
<wicket:container wicket:id="authoravatar"></wicket:container>
</div>
@@ -60,6 +63,8 @@
</div>
</div>
+ <div wicket:id="largecommitwarning"></div>
+
<div class="panel panel-default panel-diff" wicket:id="filelist">
<wicket:container wicket:id="file"></wicket:container>
</div>
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/SourceCommitPage.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/SourceCommitPage.java
index 273410056c..fdd490a16e 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/SourceCommitPage.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/SourceCommitPage.java
@@ -24,6 +24,7 @@ import com.google.common.base.Objects;
import com.google.common.collect.Lists;
import com.pmease.commons.git.Commit;
import com.pmease.gitop.model.Project;
+import com.pmease.gitop.web.common.wicket.bootstrap.Alert;
import com.pmease.gitop.web.common.wicket.bootstrap.Icon;
import com.pmease.gitop.web.component.avatar.GitPersonAvatar;
import com.pmease.gitop.web.component.label.AgeLabel;
@@ -36,6 +37,7 @@ 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.commit.patch.FileHeader;
import com.pmease.gitop.web.page.project.source.commit.patch.Patch;
+import com.pmease.gitop.web.page.project.source.commit.renderer.text.BlobDiffPanel;
@SuppressWarnings("serial")
public class SourceCommitPage extends ProjectCategoryPage {
@@ -50,6 +52,8 @@ public class SourceCommitPage extends ProjectCategoryPage {
private static final int DEFAULT_CONTEXT_LINES = 3;
+ static final int MAX_RENDERABLE_BLOBS = 500;
+
public SourceCommitPage(PageParameters params) {
super(params);
@@ -79,6 +83,8 @@ public class SourceCommitPage extends ProjectCategoryPage {
Patch patch = new DiffTreeCommand(getProject().code().repoDir())
.revision(rev)
+ .recurse(true)
+ .root(true)
.contextLines(DEFAULT_CONTEXT_LINES)
.findRenames(true)
.call();
@@ -156,6 +162,22 @@ public class SourceCommitPage extends ProjectCategoryPage {
}
};
+ add(new Label("parentslabel", new AbstractReadOnlyModel<String>() {
+
+ @Override
+ public String getObject() {
+ int parents = getCommit().getParentHashes().size();
+ if (parents == 0) {
+ return "no parent";
+ } else if (parents == 1) {
+ return "1 parent";
+ } else {
+ return parents + " parents";
+ }
+ }
+
+ }));
+
ListView<String> parentsView = new ListView<String>("parents", parentsModel) {
@Override
protected void populateItem(ListItem<String> item) {
@@ -181,7 +203,7 @@ public class SourceCommitPage extends ProjectCategoryPage {
@Override
protected List<? extends FileHeader> load() {
List<? extends FileHeader> total = getDiffPatch().getFiles();
- if (total.size() > 300) {
+ if (total.size() > MAX_RENDERABLE_BLOBS) {
return Lists.newArrayList(total.subList(0, 300));
} else {
return total;
@@ -199,6 +221,22 @@ public class SourceCommitPage extends ProjectCategoryPage {
}
});
+
+ Alert alert = new Alert("largecommitwarning",
+ Model.of("This commit contains too many changed files to render. "
+ + "Showing only the first " + MAX_RENDERABLE_BLOBS
+ + " changed files. You can still get all changes "
+ + "manually by running below command: "
+ + "<pre><code>git diff-tree -C -r ")) {
+ @Override
+ protected void onConfigure() {
+ super.onConfigure();
+ setVisibilityAllowed(getDiffPatch().getFiles().size() > MAX_RENDERABLE_BLOBS);
+ }
+ };
+
+ alert.setCloseButtonVisible(true).type(Alert.Type.Warning);
+ add(alert);
}
private void createDiffToc() {
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/patch/HunkHeader.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/patch/HunkHeader.java
index d509563af3..5e1b95fabb 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/patch/HunkHeader.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/patch/HunkHeader.java
@@ -151,6 +151,14 @@ public class HunkHeader {
return newLineCount;
}
+ public int getNewEndLine() {
+ return newStartLine + newLineCount - 1;
+ }
+
+ public int getOldEndLine() {
+ return old.startLine + old.lineCount - 1;
+ }
+
/** @return total number of lines of context appearing in this hunk */
public int getLinesContext() {
return nContext;
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/renderer/BlobDiffRenderer.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/renderer/BlobDiffRenderer.java
new file mode 100644
index 0000000000..176ddb7741
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/renderer/BlobDiffRenderer.java
@@ -0,0 +1,5 @@
+package com.pmease.gitop.web.page.project.source.commit.renderer;
+
+public interface BlobDiffRenderer {
+
+}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/BlobDiffPanel.html b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/renderer/text/BlobDiffPanel.html
similarity index 100%
rename from gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/BlobDiffPanel.html
rename to gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/renderer/text/BlobDiffPanel.html
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/BlobDiffPanel.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/renderer/text/BlobDiffPanel.java
similarity index 95%
rename from gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/BlobDiffPanel.java
rename to gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/renderer/text/BlobDiffPanel.java
index 7b72666363..ef9134eae8 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/BlobDiffPanel.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/renderer/text/BlobDiffPanel.java
@@ -1,7 +1,8 @@
-package com.pmease.gitop.web.page.project.source.commit;
+package com.pmease.gitop.web.page.project.source.commit.renderer.text;
import java.util.List;
+import org.apache.tika.mime.MediaType;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.WebMarkupContainer;
@@ -34,6 +35,7 @@ import com.pmease.gitop.web.page.project.source.commit.patch.FileHeader.PatchTyp
import com.pmease.gitop.web.page.project.source.commit.patch.HunkHeader;
import com.pmease.gitop.web.service.FileBlob;
import com.pmease.gitop.web.service.FileBlobService;
+import com.pmease.gitop.web.service.FileTypes;
@SuppressWarnings("serial")
public class BlobDiffPanel extends Panel {
@@ -158,6 +160,8 @@ public class BlobDiffPanel extends Panel {
}
if (file.getPatchType() == PatchType.BINARY) {
+ MediaType mediaType = Gitop.getInstance(FileTypes.class).getMediaType(file.getNewPath(), new byte[0]);
+ System.out.println(mediaType);
return "File is a binary file";
}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/HunkPanel.html b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/renderer/text/HunkPanel.html
similarity index 91%
rename from gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/HunkPanel.html
rename to gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/renderer/text/HunkPanel.html
index 4325e0a3ec..f3eae5d341 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/HunkPanel.html
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/renderer/text/HunkPanel.html
@@ -34,7 +34,7 @@
</div>
</div>
<div class="diff-line-code">
- <a class="add-comment"><i class="icon icon-comment-add"></i></a>
+ <a class="add-comment" wicket:id="commentlink"><i class="icon icon-comment-add"></i></a>
<pre wicket:id="code"></pre>
</div>
</div>
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/HunkPanel.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/renderer/text/HunkPanel.java
similarity index 82%
rename from gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/HunkPanel.java
rename to gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/renderer/text/HunkPanel.java
index ecf4ceaf30..9ef59be4e6 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/HunkPanel.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/renderer/text/HunkPanel.java
@@ -1,4 +1,4 @@
-package com.pmease.gitop.web.page.project.source.commit;
+package com.pmease.gitop.web.page.project.source.commit.renderer.text;
import java.util.Collections;
import java.util.List;
@@ -30,8 +30,8 @@ public class HunkPanel extends Panel {
private final int hunkIndex;
- private int aboveLines = 0;
- private int belowLines = 0;
+ private Integer aLines = null;
+ private Integer bLines = null;
public HunkPanel(String id,
IModel<FileHeader> fileModel,
@@ -61,7 +61,7 @@ public class HunkPanel extends Panel {
@Override
protected List<HunkLine> load() {
- if (aboveLines > 0) {
+ if (aLines != null) {
List<HunkLine> lines = Lists.newArrayList();
// need more context lines
@@ -71,7 +71,7 @@ public class HunkPanel extends Panel {
int newStart = getAboveNewStartLine();
List<String> blobLines = getBlobLines();
- for (int i = 0; i < aboveLines; i++) {
+ for (int i = 0; i < aLines; i++) {
HunkLine line = new HunkLine(
blobLines.get(newStart + i - 1),
LineType.CONTEXT,
@@ -84,7 +84,7 @@ public class HunkPanel extends Panel {
return Collections.emptyList();
}
}
- });
+ }, false);
}
private Component createBelowLines() {
@@ -98,12 +98,12 @@ public class HunkPanel extends Panel {
protected List<HunkLine> load() {
// Only display the last hunk
//
- if (hunkIndex == getFile().getHunks().size() - 1 && belowLines > 0) {
+ if (hunkIndex == getFile().getHunks().size() - 1 && bLines != null) {
List<HunkLine> lines = Lists.newArrayList();
HunkHeader hunk = getCurrentHunk();
int oldStart = hunk.getOldImage().getLineCount() + hunk.getOldImage().getStartLine();
int newStart = getCurrentHunk().getNewStartLine() + getCurrentHunk().getNewLineCount();
- int newEnd = newStart + belowLines;
+ int newEnd = newStart + bLines;
List<String> blobLines = getBlobLines();
for (; newStart < newEnd; newStart++, oldStart++) {
HunkLine line = new HunkLine(
@@ -119,7 +119,7 @@ public class HunkPanel extends Panel {
}
}
- });
+ }, false);
}
private Component createCurrentHunk() {
@@ -130,7 +130,7 @@ public class HunkPanel extends Panel {
return getCurrentHunk().getLines();
}
- });
+ }, true);
}
private Component createAboveHunkHead() {
@@ -162,12 +162,16 @@ public class HunkPanel extends Panel {
sb.append("@@ ");
int oldStart = getAboveOldStartLine();
int newStart = getAboveNewStartLine();
- int oldOffset = aboveLines > 0 ? aboveLines : hunk.getOldImage().getLineCount();
- int newOffset = aboveLines > 0 ? aboveLines : hunk.getNewLineCount();
+ int oldOffset = aLines == null ? hunk.getOldImage().getLineCount() : Math.min(20, aLines);
+ int newOffset = aLines == null ? hunk.getNewEndLine() : Math.min(20, aLines);
sb.append("-").append(oldStart).append(",").append(oldOffset);
sb.append(" +").append(newStart).append(",").append(newOffset);
sb.append(" @@");
+ if (aLines == null) {
+ sb.append(" ").append(hunk.getHunkFunction());
+ }
+
return sb.toString();
}
}));
@@ -185,8 +189,10 @@ public class HunkPanel extends Panel {
protected void onConfigure() {
super.onConfigure();
- int newEnd = getCurrentHunk().getNewStartLine() + getCurrentHunk().getNewLineCount() + belowLines;
- setVisibilityAllowed(newEnd < getBlobLines().size());
+ if (bLines != null) {
+ int newEnd = getCurrentHunk().getNewStartLine() + getCurrentHunk().getNewLineCount() + bLines;
+ setVisibilityAllowed(newEnd < getBlobLines().size());
+ }
}
};
@@ -202,11 +208,12 @@ public class HunkPanel extends Panel {
}
void expandBelowLines() {
- belowLines += 20;
+ bLines = bLines == null ? 20 : bLines + 20;
HunkHeader hunk = getCurrentHunk();
- int newEnd = hunk.getNewStartLine() + hunk.getNewLineCount() + belowLines;
- if (newEnd > getBlobLines().size()) {
- belowLines = getBlobLines().size() - hunk.getNewLineCount() - hunk.getNewStartLine();
+ int newEnd = hunk.getNewEndLine() + bLines;
+ int totalLines = getBlobLines().size();
+ if (newEnd > totalLines) {
+ bLines = totalLines - hunk.getNewEndLine();
}
}
@@ -221,7 +228,7 @@ public class HunkPanel extends Panel {
target.add(belowLines);
}
- Component createHunkLines(String id, IModel<List<HunkLine>> linesModel) {
+ Component createHunkLines(String id, IModel<List<HunkLine>> linesModel, final boolean withComment) {
Fragment frag = new Fragment(id, "linefrag", this);
frag.setOutputMarkupId(true);
frag.add(new ListView<HunkLine>("lines", linesModel) {
@@ -246,6 +253,8 @@ public class HunkPanel extends Panel {
item.add(new Label("oldlineno", oldLineNo).setEscapeModelStrings(false));
item.add(new Label("newlineno", newLineNo).setEscapeModelStrings(false));
item.add(new Label("code", line.getText()));
+
+ item.add(new WebMarkupContainer("commentlink").setVisibilityAllowed(withComment));
}
});
@@ -255,11 +264,13 @@ public class HunkPanel extends Panel {
private int getAboveOldStartLine() {
HunkHeader currentHunk = getCurrentHunk();
- return currentHunk.getOldImage().getStartLine() - aboveLines;
+ return aLines == null ? currentHunk.getOldImage().getStartLine() :
+ currentHunk.getOldImage().getStartLine() - aLines;
}
private int getAboveNewStartLine() {
- return getCurrentHunk().getNewStartLine() - aboveLines;
+ return aLines == null ? getCurrentHunk().getNewStartLine() :
+ getCurrentHunk().getNewEndLine() - aLines;
}
private HunkHeader getCurrentHunk() {
@@ -288,17 +299,16 @@ public class HunkPanel extends Panel {
}
private void expandAboveLines() {
- aboveLines += 20;
+ aLines = aLines == null ? 20 : aLines + 20;
- int startLine = getCurrentHunk().getNewStartLine();
- startLine -= aboveLines;
+ int startLine = getCurrentHunk().getNewStartLine() - aLines;
startLine = Math.max(1, startLine);
HunkHeader previous = getPreviousHunk();
if (previous != null) {
- startLine = Math.max(previous.getNewStartLine() + previous.getNewLineCount(), startLine);
+ startLine = Math.max(previous.getNewEndLine() + 1, startLine);
}
- aboveLines = getCurrentHunk().getNewStartLine() - startLine;
+ aLines = getCurrentHunk().getNewStartLine() - startLine;
}
private void onExpandAbove(AjaxRequestTarget target) {
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/renderer/text/TextFileDiffRenderer.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/renderer/text/TextFileDiffRenderer.java
new file mode 100644
index 0000000000..b2b4f2f66a
--- /dev/null
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commit/renderer/text/TextFileDiffRenderer.java
@@ -0,0 +1,7 @@
+package com.pmease.gitop.web.page.project.source.commit.renderer.text;
+
+import com.pmease.gitop.web.page.project.source.commit.renderer.BlobDiffRenderer;
+
+public class TextFileDiffRenderer implements BlobDiffRenderer {
+
+}
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commits/CommitsPanel.html b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commits/CommitsPanel.html
index 17fd19d4c7..116d11fec2 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commits/CommitsPanel.html
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/source/commits/CommitsPanel.html
@@ -7,8 +7,8 @@
<wicket:container wicket:id="authoravatar"></wicket:container>
<div class="right">
<div class="commitish">
- <a class="btn btn-default btn-xs" wicket:id="commitlink"><span class="sha" wicket:id="sha"></span></a>
- <a class="browse-link" wicket:id="treelink">Browse code</a>
+ <a class="sha" wicket:id="commitlink"><span class="" wicket:id="sha"></span> &rarr;</a>
+ <a class="sha" wicket:id="treelink">Browse code &raquo;</a>
</div>
</div>