]> source.dussan.org Git - gitblit.git/commitdiff
Color-coded change type indicator with tooltip for changed paths.
authorJames Moger <james.moger@gitblit.com>
Tue, 19 Apr 2011 02:29:20 +0000 (22:29 -0400)
committerJames Moger <james.moger@gitblit.com>
Tue, 19 Apr 2011 02:29:20 +0000 (22:29 -0400)
Also fixed /dev/null reference due to deletion change.

13 files changed:
gitblit.properties
src/com/gitblit/tests/JGitUtilsTest.java
src/com/gitblit/utils/JGitUtils.java
src/com/gitblit/wicket/GitBlitWebApp.properties
src/com/gitblit/wicket/RepositoryPage.java
src/com/gitblit/wicket/WicketUtils.java
src/com/gitblit/wicket/models/PathModel.java
src/com/gitblit/wicket/pages/CommitDiffPage.html
src/com/gitblit/wicket/pages/CommitDiffPage.java
src/com/gitblit/wicket/pages/CommitPage.html
src/com/gitblit/wicket/pages/CommitPage.java
src/com/gitblit/wicket/panels/HistoryPanel.java
src/com/gitblit/wicket/resources/gitblit.css

index ecefedfbc1b8e97128394e77adf6d4e8f7998e30..a81e5f618a7bca77e70f791df3bc308f7527e237 100644 (file)
@@ -130,11 +130,11 @@ server.httpsPort = 443
 \r
 # Specify the interface for Jetty to bind the standard connector.\r
 # You may specify an ip or an empty value to bind to all interfaces. \r
-server.httpBindInterface = localhost\r
+server.httpBindInterface = \r
 \r
 # Specify the interface for Jetty to bind the secure connector.\r
 # You may specify an ip or an empty value to bind to all interfaces.\r
-server.httpsBindInterface = localhost\r
+server.httpsBindInterface = \r
 \r
 # Password for SSL keystore (keystore password and certificate password must match)\r
 server.storePassword = dosomegit\r
index b6b497f0ef8d8cbafbc2ea34438097b7968f4dcb..0ebcd71e34c67572138afa658d210760ad7163ad 100644 (file)
@@ -15,7 +15,7 @@ import org.eclipse.jgit.revwalk.RevTree;
 import org.eclipse.jgit.storage.file.FileRepository;\r
 \r
 import com.gitblit.utils.JGitUtils;\r
-import com.gitblit.wicket.models.PathModel;\r
+import com.gitblit.wicket.models.PathModel.PathChangeModel;\r
 import com.gitblit.wicket.models.RefModel;\r
 import com.gitblit.wicket.models.TicketModel;\r
 \r
@@ -82,7 +82,7 @@ public class JGitUtilsTest extends TestCase {
        public void testFilesInCommit() throws Exception {\r
                Repository r = getRepository();\r
                RevCommit commit = JGitUtils.getCommit(r, Constants.HEAD);\r
-               List<PathModel> paths = JGitUtils.getFilesInCommit(r, commit);\r
+               List<PathChangeModel> paths = JGitUtils.getFilesInCommit(r, commit);\r
                r.close();\r
                assertTrue("No changed paths found!", paths.size() > 0);\r
        }\r
index 49fbf1ef89d475cb34d878f65338e43fff74c829..b1267685ed83e0249d2c8876b5ae296788582028 100644 (file)
@@ -19,6 +19,7 @@ import java.util.Set;
 import org.eclipse.jgit.diff.DiffEntry;\r
 import org.eclipse.jgit.diff.DiffFormatter;\r
 import org.eclipse.jgit.diff.RawTextComparator;\r
+import org.eclipse.jgit.diff.DiffEntry.ChangeType;\r
 import org.eclipse.jgit.errors.ConfigInvalidException;\r
 import org.eclipse.jgit.errors.IncorrectObjectTypeException;\r
 import org.eclipse.jgit.errors.MissingObjectException;\r
@@ -49,6 +50,7 @@ import org.slf4j.LoggerFactory;
 \r
 import com.gitblit.wicket.models.Metric;\r
 import com.gitblit.wicket.models.PathModel;\r
+import com.gitblit.wicket.models.PathModel.PathChangeModel;\r
 import com.gitblit.wicket.models.RefModel;\r
 import com.gitblit.wicket.models.TicketModel;\r
 import com.gitblit.wicket.models.TicketModel.Comment;\r
@@ -256,13 +258,13 @@ public class JGitUtils {
                return list;\r
        }\r
 \r
-       public static List<PathModel> getFilesInCommit(Repository r, String commitId) {\r
+       public static List<PathChangeModel> getFilesInCommit(Repository r, String commitId) {\r
                RevCommit commit = getCommit(r, commitId);\r
                return getFilesInCommit(r, commit);\r
        }\r
 \r
-       public static List<PathModel> getFilesInCommit(Repository r, RevCommit commit) {\r
-               List<PathModel> list = new ArrayList<PathModel>();\r
+       public static List<PathChangeModel> getFilesInCommit(Repository r, RevCommit commit) {\r
+               List<PathChangeModel> list = new ArrayList<PathChangeModel>();\r
                try {\r
                        final RevWalk rw = new RevWalk(r);\r
                        RevCommit parent = rw.parseCommit(commit.getParent(0).getId());\r
@@ -283,7 +285,11 @@ public class JGitUtils {
                        df.setDetectRenames(true);\r
                        List<DiffEntry> diffs = df.scan(parentTree, commitTree);\r
                        for (DiffEntry diff : diffs) {\r
-                               list.add(new PathModel(diff.getNewPath(), diff.getNewPath(), 0, diff.getNewMode().getBits(), commit.getId().getName()));\r
+                               if (diff.getChangeType().equals(ChangeType.DELETE)) {\r
+                                       list.add(new PathChangeModel(diff.getOldPath(), diff.getOldPath(), 0, diff.getNewMode().getBits(), commit.getId().getName(), diff.getChangeType()));\r
+                               } else {\r
+                                       list.add(new PathChangeModel(diff.getNewPath(), diff.getNewPath(), 0, diff.getNewMode().getBits(), commit.getId().getName(), diff.getChangeType()));\r
+                               }\r
                        }\r
                } catch (Throwable t) {\r
                        LOGGER.error("failed to determine files in commit!", t);\r
index ca757768b6c1c3634b7a73b1da5694333ac78027..b8d31ae578b1ecbcde854d410eeb4f297e709a37 100644 (file)
@@ -50,4 +50,8 @@ gb.moreHistory = more history...
 gb.difftocurrent = diff to current\r
 gb.search = search\r
 gb.searchForAuthor = Search for commits authored by\r
-gb.searchForCommitter = Search for commits committed by
\ No newline at end of file
+gb.searchForCommitter = Search for commits committed by\r
+gb.addition = addition\r
+gb.modification = modification\r
+gb.deletion = deletion\r
+gb.rename = rename
\ No newline at end of file
index 6442bee8df416f8adfbbb859e571de3aaaf8a3c9..979debda611dbba60ab310600a93a9fa03705221 100644 (file)
@@ -11,6 +11,7 @@ import org.apache.wicket.PageParameters;
 import org.apache.wicket.markup.html.basic.Label;\r
 import org.apache.wicket.markup.html.panel.Fragment;\r
 import org.apache.wicket.protocol.http.servlet.ServletWebRequest;\r
+import org.eclipse.jgit.diff.DiffEntry.ChangeType;\r
 import org.eclipse.jgit.lib.PersonIdent;\r
 import org.eclipse.jgit.lib.Repository;\r
 import org.eclipse.jgit.revwalk.RevCommit;\r
@@ -146,6 +147,25 @@ public abstract class RepositoryPage extends BasePage {
                        WicketUtils.setHtmlTitle(component, getString("gb.searchForCommitter") + " " + value);\r
                }\r
        }\r
+       \r
+       protected void setChangeTypeTooltip(Component container, ChangeType type) {\r
+               switch (type) {\r
+               case ADD:\r
+                       WicketUtils.setHtmlTitle(container, getString("gb.addition"));\r
+                       break;\r
+               case COPY:\r
+               case RENAME:\r
+                       WicketUtils.setHtmlTitle(container, getString("gb.rename"));\r
+                       break;\r
+               case DELETE:\r
+                       WicketUtils.setHtmlTitle(container, getString("gb.deletion"));\r
+                       break;\r
+               case MODIFY:\r
+                       WicketUtils.setHtmlTitle(container, getString("gb.modification"));\r
+                       break;\r
+               }\r
+       }\r
+       \r
        @Override\r
        protected void onBeforeRender() {\r
                // dispose of repository object\r
index e47432578db5e44301deb9d570a577cfd0128799..c8d605ba751493f1fe3a779838aa995a8f4c2b8b 100644 (file)
@@ -9,6 +9,7 @@ import org.apache.wicket.Component;
 import org.apache.wicket.PageParameters;\r
 import org.apache.wicket.behavior.SimpleAttributeModifier;\r
 import org.apache.wicket.markup.html.basic.Label;\r
+import org.eclipse.jgit.diff.DiffEntry.ChangeType;\r
 import org.eclipse.jgit.lib.Constants;\r
 \r
 import com.gitblit.GitBlit;\r
@@ -31,6 +32,24 @@ public class WicketUtils {
                container.add(new SimpleAttributeModifier("title", value));\r
        }\r
 \r
+       public static void setChangeTypeCssClass(Component container, ChangeType type) {\r
+               switch (type) {\r
+               case ADD:\r
+                       setCssClass(container, "addition");\r
+                       break;\r
+               case COPY:\r
+               case RENAME:\r
+                       setCssClass(container, "rename");\r
+                       break;\r
+               case DELETE:\r
+                       setCssClass(container, "deletion");\r
+                       break;\r
+               case MODIFY:\r
+                       setCssClass(container, "modification");\r
+                       break;\r
+               }\r
+       }\r
+\r
        public static void setTicketCssClass(Component container, String state) {\r
                String css = null;\r
                if (state.equals("open")) {\r
@@ -96,7 +115,7 @@ public class WicketUtils {
 \r
        public static PageParameters newSearchParameter(String repositoryName, String commitId, String search, SearchType type) {\r
                if (StringUtils.isEmpty(commitId)) {\r
-                       return new PageParameters("r=" + repositoryName + ",s=" + search + ",st=" + type.name());       \r
+                       return new PageParameters("r=" + repositoryName + ",s=" + search + ",st=" + type.name());\r
                }\r
                return new PageParameters("r=" + repositoryName + ",h=" + commitId + ",s=" + search + ",st=" + type.name());\r
        }\r
index e2e463f9d04231011efd84a536d351afbf9b70c8..2895d568c51018161daceb2738041b0c7e78661e 100644 (file)
@@ -2,6 +2,8 @@ package com.gitblit.wicket.models;
 \r
 import java.io.Serializable;\r
 \r
+import org.eclipse.jgit.diff.DiffEntry.ChangeType;\r
+\r
 import com.gitblit.utils.JGitUtils;\r
 \r
 public class PathModel implements Serializable, Comparable<PathModel> {\r
@@ -50,4 +52,16 @@ public class PathModel implements Serializable, Comparable<PathModel> {
                }\r
                return 1;\r
        }\r
+\r
+       public static class PathChangeModel extends PathModel {\r
+               \r
+               private static final long serialVersionUID = 1L;\r
+               \r
+               public final ChangeType changeType;\r
+\r
+               public PathChangeModel(String name, String path, long size, int mode, String commitId, ChangeType type) {\r
+                       super(name, path, size, mode, commitId);\r
+                       this.changeType = type;\r
+               }\r
+       }\r
 }\r
index af731a0d8b69179dbd79f55966a57190fec25a8a..a3a480b5da3c6e06f0790b60e9be88a46d7989e6 100644 (file)
@@ -21,6 +21,7 @@
        <!-- changed paths -->\r
        <table style="margin-top:10px;border-top:1px solid #bbb;" class="pretty">\r
                <tr wicket:id="changedPath">\r
+                       <td><span wicket:id="changeType">[change type]</span></td>              \r
                        <td class="path"><span wicket:id="pathName">[commit path]</span></td>                   \r
                        <td>\r
                                <span class="link">\r
index 87e81102779ab76917523aa711eb636e67862801..d52b7a366826927dc90c09d04def1017ba0813b6 100644 (file)
@@ -16,7 +16,7 @@ import com.gitblit.utils.JGitUtils;
 import com.gitblit.wicket.LinkPanel;\r
 import com.gitblit.wicket.RepositoryPage;\r
 import com.gitblit.wicket.WicketUtils;\r
-import com.gitblit.wicket.models.PathModel;\r
+import com.gitblit.wicket.models.PathModel.PathChangeModel;\r
 \r
 public class CommitDiffPage extends RepositoryPage {\r
 \r
@@ -46,14 +46,19 @@ public class CommitDiffPage extends RepositoryPage {
                add(new LinkPanel("shortlog", "title", commit.getShortMessage(), CommitPage.class, newCommitParameter()));\r
 \r
                // changed paths list\r
-               List<PathModel> paths = JGitUtils.getFilesInCommit(r, commit);\r
-               ListDataProvider<PathModel> pathsDp = new ListDataProvider<PathModel>(paths);\r
-               DataView<PathModel> pathsView = new DataView<PathModel>("changedPath", pathsDp) {\r
+               List<PathChangeModel> paths = JGitUtils.getFilesInCommit(r, commit);\r
+               ListDataProvider<PathChangeModel> pathsDp = new ListDataProvider<PathChangeModel>(paths);\r
+               DataView<PathChangeModel> pathsView = new DataView<PathChangeModel>("changedPath", pathsDp) {\r
                        private static final long serialVersionUID = 1L;\r
                        int counter = 0;\r
 \r
-                       public void populateItem(final Item<PathModel> item) {\r
-                               final PathModel entry = item.getModelObject();\r
+                       public void populateItem(final Item<PathChangeModel> item) {\r
+                               final PathChangeModel entry = item.getModelObject();\r
+                               Label changeType = new Label("changeType", "");\r
+                               WicketUtils.setChangeTypeCssClass(changeType, entry.changeType);\r
+                               setChangeTypeTooltip(changeType, entry.changeType);\r
+                               item.add(changeType);\r
+\r
                                if (entry.isTree()) {\r
                                        item.add(new LinkPanel("pathName", null, entry.path, TreePage.class, newPathParameter(entry.path)));\r
                                } else {\r
index ec1b55df6a7a773873470732637db19fcc1a0948..87547fca80e2d77a5c564787004ad98755f33576 100644 (file)
@@ -45,6 +45,7 @@
        <!-- changed paths -->\r
        <table style="border-top:1px solid #bbb;" class="pretty">\r
                <tr wicket:id="changedPath">\r
+                       <td><span wicket:id="changeType">[change type]</span></td>\r
                        <td class="path"><span wicket:id="pathName">[commit path]</span></td>                   \r
                        <td>\r
                                <span class="link">\r
index 064a7fe529a8ba992e6eb2acc46024fe3e4e281a..04065233c97561b0478cd39265bc15090ee2e1bb 100644 (file)
@@ -18,7 +18,7 @@ import com.gitblit.utils.JGitUtils.SearchType;
 import com.gitblit.wicket.LinkPanel;\r
 import com.gitblit.wicket.RepositoryPage;\r
 import com.gitblit.wicket.WicketUtils;\r
-import com.gitblit.wicket.models.PathModel;\r
+import com.gitblit.wicket.models.PathModel.PathChangeModel;\r
 \r
 public class CommitPage extends RepositoryPage {\r
 \r
@@ -78,14 +78,18 @@ public class CommitPage extends RepositoryPage {
                addFullText("fullMessage", c.getFullMessage(), true);\r
 \r
                // changed paths list\r
-               List<PathModel> paths = JGitUtils.getFilesInCommit(r, c);\r
-               ListDataProvider<PathModel> pathsDp = new ListDataProvider<PathModel>(paths);\r
-               DataView<PathModel> pathsView = new DataView<PathModel>("changedPath", pathsDp) {\r
+               List<PathChangeModel> paths = JGitUtils.getFilesInCommit(r, c);\r
+               ListDataProvider<PathChangeModel> pathsDp = new ListDataProvider<PathChangeModel>(paths);\r
+               DataView<PathChangeModel> pathsView = new DataView<PathChangeModel>("changedPath", pathsDp) {\r
                        private static final long serialVersionUID = 1L;\r
                        int counter = 0;\r
 \r
-                       public void populateItem(final Item<PathModel> item) {\r
-                               final PathModel entry = item.getModelObject();\r
+                       public void populateItem(final Item<PathChangeModel> item) {\r
+                               final PathChangeModel entry = item.getModelObject();\r
+                               Label changeType = new Label("changeType", "");\r
+                               WicketUtils.setChangeTypeCssClass(changeType, entry.changeType);\r
+                               setChangeTypeTooltip(changeType, entry.changeType);\r
+                               item.add(changeType);\r
                                if (entry.isTree()) {\r
                                        item.add(new LinkPanel("pathName", null, entry.path, TreePage.class, newPathParameter(entry.path)));\r
                                } else {\r
index dd1395a700766f8693b083417e88d3141310fba8..e68fc1abf0acf385b30b4cf70f2ccb93f64ee485 100644 (file)
@@ -18,11 +18,12 @@ import org.eclipse.jgit.revwalk.RevCommit;
 import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.utils.JGitUtils;\r
-import com.gitblit.utils.StringUtils;\r
 import com.gitblit.utils.JGitUtils.SearchType;\r
+import com.gitblit.utils.StringUtils;\r
 import com.gitblit.wicket.LinkPanel;\r
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.models.PathModel;\r
+import com.gitblit.wicket.models.PathModel.PathChangeModel;\r
 import com.gitblit.wicket.pages.BlobDiffPage;\r
 import com.gitblit.wicket.pages.BlobPage;\r
 import com.gitblit.wicket.pages.CommitDiffPage;\r
@@ -47,7 +48,7 @@ public class HistoryPanel extends BasePanel {
                }\r
 \r
                RevCommit commit = JGitUtils.getCommit(r, objectId);\r
-               List<PathModel> paths = JGitUtils.getFilesInCommit(r, commit);\r
+               List<PathChangeModel> paths = JGitUtils.getFilesInCommit(r, commit);\r
 \r
                PathModel matchingPath = null;\r
                for (PathModel p : paths) {\r
index 8264cbb5958d9ae76e9dc316d0f6145908bddfcb..d3d68b7a10cd46b87e640f5b91d8a13c555a37f2 100644 (file)
@@ -169,7 +169,7 @@ div.search {
        color:yellow;\r
        text-align:right;\r
        float:right;\r
-       padding:3px;\r
+       padding:3px 4px 3px 3px;        \r
 }\r
 \r
 .repositories_message {\r
@@ -281,6 +281,31 @@ span.diff.hunk_section {
        font-family: inherit;\r
 }\r
 \r
+span.addition, span.modification, span.deletion, span.rename {\r
+       border: 1px solid #888;\r
+       float: left;\r
+       height: 0.8em;\r
+       margin: 0.2em 0.5em 0 0;\r
+       overflow: hidden;\r
+       width: 0.8em;\r
+}\r
+\r
+span.addition {\r
+       background-color: #bbffbb;\r
+}\r
+\r
+span.modification {\r
+       background-color: #ffdd88;\r
+}\r
+\r
+span.deletion {\r
+       background-color: #ff8888;\r
+}\r
+\r
+span.rename {\r
+       background-color: #8888ff;\r
+}\r
+\r
 a.list {\r
        text-decoration: none;\r
        color: #000000;\r