]> source.dussan.org Git - gitblit.git/commitdiff
Fixed refs linking problem. Author metrics are lowercase.
authorJames Moger <james.moger@gitblit.com>
Sat, 4 Jun 2011 18:23:55 +0000 (14:23 -0400)
committerJames Moger <james.moger@gitblit.com>
Sat, 4 Jun 2011 18:23:55 +0000 (14:23 -0400)
distrib/users.properties
src/com/gitblit/utils/JGitUtils.java
src/com/gitblit/utils/MetricUtils.java
src/com/gitblit/utils/TicgitUtils.java
src/com/gitblit/wicket/pages/TagPage.java
src/com/gitblit/wicket/panels/BranchesPanel.java
src/com/gitblit/wicket/panels/RefsPanel.java
src/com/gitblit/wicket/panels/TagsPanel.java
tests/com/gitblit/tests/JGitUtilsTest.java

index a7ebc67870804ed403bfa07193bac7af6a543568..f3e50752296c0255b31bd2c426d224cc3c74c91b 100644 (file)
@@ -1,3 +1,3 @@
 ## Git:Blit realm file format: username=password,\#permission,repository1,repository2...\r
-#Thu Jun 02 22:11:15 EDT 2011\r
+#Sat Jun 04 14:21:04 EDT 2011\r
 admin=admin,\#admin\r
index 2590a30005c5390263473a7e3c209425977f073c..6e02b9c490e37347523e90ec6a0820324c288731 100644 (file)
@@ -211,7 +211,7 @@ public class JGitUtils {
        }\r
 \r
        public static Map<ObjectId, List<RefModel>> getAllRefs(Repository r) {\r
-               List<RefModel> list = getRefs(r, org.eclipse.jgit.lib.RefDatabase.ALL, -1);\r
+               List<RefModel> list = getRefs(r, org.eclipse.jgit.lib.RefDatabase.ALL, true, -1);\r
                Map<ObjectId, List<RefModel>> refs = new HashMap<ObjectId, List<RefModel>>();\r
                for (RefModel ref : list) {\r
                        ObjectId objectid = ref.getReferencedObjectId();\r
@@ -613,23 +613,23 @@ public class JGitUtils {
                return list;\r
        }\r
 \r
-       public static List<RefModel> getTags(Repository r, int maxCount) {\r
-               return getRefs(r, Constants.R_TAGS, maxCount);\r
+       public static List<RefModel> getTags(Repository r, boolean fullName, int maxCount) {\r
+               return getRefs(r, Constants.R_TAGS, fullName, maxCount);\r
        }\r
 \r
-       public static List<RefModel> getLocalBranches(Repository r, int maxCount) {\r
-               return getRefs(r, Constants.R_HEADS, maxCount);\r
+       public static List<RefModel> getLocalBranches(Repository r, boolean fullName, int maxCount) {\r
+               return getRefs(r, Constants.R_HEADS, fullName, maxCount);\r
        }\r
 \r
-       public static List<RefModel> getRemoteBranches(Repository r, int maxCount) {\r
-               return getRefs(r, Constants.R_REMOTES, maxCount);\r
+       public static List<RefModel> getRemoteBranches(Repository r, boolean fullName, int maxCount) {\r
+               return getRefs(r, Constants.R_REMOTES, fullName, maxCount);\r
        }\r
 \r
-       public static List<RefModel> getNotesRefs(Repository r, int maxCount) {\r
-               return getRefs(r, Constants.R_NOTES, maxCount);\r
+       public static List<RefModel> getNotesRefs(Repository r, boolean fullName, int maxCount) {\r
+               return getRefs(r, Constants.R_NOTES, fullName, maxCount);\r
        }\r
 \r
-       private static List<RefModel> getRefs(Repository r, String refs, int maxCount) {\r
+       private static List<RefModel> getRefs(Repository r, String refs, boolean fullName, int maxCount) {\r
                List<RefModel> list = new ArrayList<RefModel>();\r
                try {\r
                        Map<String, Ref> map = r.getRefDatabase().getRefs(refs);\r
@@ -637,7 +637,11 @@ public class JGitUtils {
                        for (Entry<String, Ref> entry : map.entrySet()) {\r
                                Ref ref = entry.getValue();\r
                                RevObject object = rw.parseAny(ref.getObjectId());\r
-                               list.add(new RefModel(entry.getKey(), ref, object));\r
+                               String name = entry.getKey();\r
+                               if (fullName && !StringUtils.isEmpty(refs)) {\r
+                                       name = refs + name;\r
+                               }\r
+                               list.add(new RefModel(name, ref, object));\r
                        }\r
                        rw.dispose();\r
                        Collections.sort(list);\r
@@ -653,7 +657,7 @@ public class JGitUtils {
 \r
        public static List<GitNote> getNotesOnCommit(Repository repository, RevCommit commit) {\r
                List<GitNote> list = new ArrayList<GitNote>();\r
-               List<RefModel> notesRefs = getNotesRefs(repository, -1);\r
+               List<RefModel> notesRefs = getNotesRefs(repository, true, -1);\r
                for (RefModel notesRef : notesRefs) {\r
                        RevTree notesTree = JGitUtils.getCommit(repository, notesRef.getName()).getTree();\r
                        StringBuilder sb = new StringBuilder(commit.getName());\r
index d963bf58fe577fedc8edc8fd7ad0c53e4765bccb..d8286e290291b1b756660c460eb30e3f7567c189 100644 (file)
@@ -44,7 +44,7 @@ public class MetricUtils {
                final Map<String, Metric> metricMap = new HashMap<String, Metric>();\r
 \r
                if (JGitUtils.hasCommits(r)) {\r
-                       final List<RefModel> tags = JGitUtils.getTags(r, -1);\r
+                       final List<RefModel> tags = JGitUtils.getTags(r, true, -1);\r
                        final Map<ObjectId, RefModel> tagMap = new HashMap<ObjectId, RefModel>();\r
                        for (RefModel tag : tags) {\r
                                tagMap.put(tag.getReferencedObjectId(), tag);\r
@@ -122,14 +122,14 @@ public class MetricUtils {
                                for (RevCommit rev : revlog) {\r
                                        String p;\r
                                        if (byEmail) {\r
-                                               p = rev.getAuthorIdent().getEmailAddress();\r
+                                               p = rev.getAuthorIdent().getEmailAddress().toLowerCase();\r
                                                if (StringUtils.isEmpty(p)) {\r
-                                                       p = rev.getAuthorIdent().getName();\r
+                                                       p = rev.getAuthorIdent().getName().toLowerCase();\r
                                                }\r
                                        } else {\r
-                                               p = rev.getAuthorIdent().getName();\r
+                                               p = rev.getAuthorIdent().getName().toLowerCase();\r
                                                if (StringUtils.isEmpty(p)) {\r
-                                                       p = rev.getAuthorIdent().getEmailAddress();\r
+                                                       p = rev.getAuthorIdent().getEmailAddress().toLowerCase();\r
                                                }\r
                                        }\r
                                        if (!metricMap.containsKey(p)) {\r
index 8224d1cb4518cd4516d33cd0ff1d90b9c7f5a7c4..48e8558c98449178d3c0188f1b479c86134d2387 100644 (file)
@@ -38,7 +38,7 @@ public class TicgitUtils {
                RefModel ticgitBranch = null;\r
                try {\r
                        // search for ticgit branch in local heads\r
-                       for (RefModel ref : JGitUtils.getLocalBranches(r, -1)) {\r
+                       for (RefModel ref : JGitUtils.getLocalBranches(r, false, -1)) {\r
                                if (ref.displayName.endsWith("ticgit")) {\r
                                        ticgitBranch = ref;\r
                                        break;\r
@@ -47,7 +47,7 @@ public class TicgitUtils {
 \r
                        // search for ticgit branch in remote heads\r
                        if (ticgitBranch == null) {\r
-                               for (RefModel ref : JGitUtils.getRemoteBranches(r, -1)) {\r
+                               for (RefModel ref : JGitUtils.getRemoteBranches(r, false, -1)) {\r
                                        if (ref.displayName.endsWith("ticgit")) {\r
                                                ticgitBranch = ref;\r
                                                break;\r
index 71a86452cf7755191e49c66d7e3b4f6aedec8efa..c1efb8986d47cbb4be1a0fda99ac058441214b69 100644 (file)
@@ -39,7 +39,7 @@ public class TagPage extends RepositoryPage {
                Repository r = getRepository();\r
 \r
                // Find tag in repository\r
-               List<RefModel> tags = JGitUtils.getTags(r, -1);\r
+               List<RefModel> tags = JGitUtils.getTags(r, true, -1);\r
                RefModel tagRef = null;\r
                for (RefModel tag : tags) {\r
                        if (tag.getName().equals(objectId) || tag.getObjectId().getName().equals(objectId)) {\r
index d50db88348433b561c0f231788db923b93b95d56..82f8a04559a685b643dc04ae30d2c46009cf9704 100644 (file)
@@ -48,9 +48,9 @@ public class BranchesPanel extends BasePanel {
 \r
                // branches\r
                List<RefModel> branches = new ArrayList<RefModel>();\r
-               branches.addAll(JGitUtils.getLocalBranches(r, maxCount));\r
+               branches.addAll(JGitUtils.getLocalBranches(r, false, maxCount));\r
                if (model.showRemoteBranches) {\r
-                       branches.addAll(JGitUtils.getRemoteBranches(r, maxCount));\r
+                       branches.addAll(JGitUtils.getRemoteBranches(r, false, maxCount));\r
                }\r
                Collections.sort(branches);\r
                Collections.reverse(branches);\r
index 266a49b73a649d46605f87116baccfcc50c5cc96..8cf137b16d1edb06528aebd2b9bf15c816849c8c 100644 (file)
@@ -17,6 +17,7 @@ package com.gitblit.wicket.panels;
 \r
 import java.util.ArrayList;\r
 import java.util.Collections;\r
+import java.util.Comparator;\r
 import java.util.List;\r
 import java.util.Map;\r
 \r
@@ -33,6 +34,7 @@ import com.gitblit.models.RefModel;
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.pages.CommitPage;\r
 import com.gitblit.wicket.pages.LogPage;\r
+import com.gitblit.wicket.pages.RepositoryPage;\r
 import com.gitblit.wicket.pages.TagPage;\r
 \r
 public class RefsPanel extends Panel {\r
@@ -49,8 +51,12 @@ public class RefsPanel extends Panel {
                if (refs == null) {\r
                        refs = new ArrayList<RefModel>();\r
                }\r
-               Collections.sort(refs);\r
-               // refNames.remove(Constants.HEAD);\r
+               Collections.sort(refs, new Comparator<RefModel>() {\r
+                       @Override\r
+                       public int compare(RefModel o1, RefModel o2) {\r
+                               return o1.displayName.compareTo(o2.displayName);\r
+                       }\r
+               });\r
 \r
                ListDataProvider<RefModel> refsDp = new ListDataProvider<RefModel>(refs);\r
                DataView<RefModel> refsView = new DataView<RefModel>("ref", refsDp) {\r
@@ -60,34 +66,42 @@ public class RefsPanel extends Panel {
                                RefModel entry = item.getModelObject();\r
                                String name = entry.displayName;\r
                                String objectid = entry.getReferencedObjectId().getName();\r
-                               Component c = null;\r
+\r
+                               Class<? extends RepositoryPage> linkClass = CommitPage.class;\r
+                               String cssClass = "";\r
                                if (name.startsWith(Constants.R_HEADS)) {\r
                                        // local head\r
-                                       c = new LinkPanel("refName", null, name.substring(Constants.R_HEADS.length()),\r
-                                                       LogPage.class, WicketUtils.newObjectParameter(repositoryName, objectid));\r
-                                       WicketUtils.setCssClass(c, "headRef");\r
+                                       linkClass = LogPage.class;\r
+                                       name = name.substring(Constants.R_HEADS.length());\r
+                                       cssClass = "headRef";\r
                                } else if (name.equals(Constants.HEAD)) {\r
                                        // local head\r
-                                       c = new LinkPanel("refName", null, name, LogPage.class,\r
-                                                       WicketUtils.newObjectParameter(repositoryName, objectid));\r
-                                       WicketUtils.setCssClass(c, "headRef");\r
+                                       linkClass = LogPage.class;\r
+                                       cssClass = "headRef";\r
                                } else if (name.startsWith(Constants.R_REMOTES)) {\r
                                        // remote head\r
-                                       c = new LinkPanel("refName", null,\r
-                                                       name.substring(Constants.R_REMOTES.length()), LogPage.class,\r
-                                                       WicketUtils.newObjectParameter(repositoryName, objectid));\r
-                                       WicketUtils.setCssClass(c, "remoteRef");\r
+                                       linkClass = LogPage.class;\r
+                                       name = name.substring(Constants.R_REMOTES.length());\r
+                                       cssClass = "remoteRef";\r
                                } else if (name.startsWith(Constants.R_TAGS)) {\r
                                        // tag\r
-                                       c = new LinkPanel("refName", null, name.substring(Constants.R_TAGS.length()),\r
-                                                       TagPage.class, WicketUtils.newObjectParameter(repositoryName, objectid));\r
-                                       WicketUtils.setCssClass(c, "tagRef");\r
-                               } else {\r
-                                       // other\r
-                                       c = new LinkPanel("refName", null, name, CommitPage.class,\r
-                                                       WicketUtils.newObjectParameter(repositoryName, objectid));\r
-                                       WicketUtils.setCssClass(c, "otherRef");\r
+                                       if (entry.isAnnotatedTag()) {\r
+                                               linkClass = TagPage.class;\r
+                                               objectid = entry.getObjectId().getName();\r
+                                       } else {\r
+                                               linkClass = CommitPage.class;\r
+                                               objectid = entry.getReferencedObjectId().getName();\r
+                                       }\r
+                                       name = name.substring(Constants.R_TAGS.length());\r
+                                       cssClass = "tagRef";\r
+                               } else if (name.startsWith(Constants.R_NOTES)) {\r
+                                       linkClass = CommitPage.class;\r
+                                       cssClass = "otherRef";\r
                                }\r
+\r
+                               Component c = new LinkPanel("refName", null, name, linkClass,\r
+                                               WicketUtils.newObjectParameter(repositoryName, objectid));\r
+                               WicketUtils.setCssClass(c, cssClass);\r
                                WicketUtils.setHtmlTooltip(c, name);\r
                                item.add(c);\r
                        }\r
index 259af312da0baa208a25eb72599f9e0903abc790..f6dd762bb585c1d37adc5e57be2539ea17505c5c 100644 (file)
@@ -49,7 +49,7 @@ public class TagsPanel extends BasePanel {
                super(wicketId);\r
 \r
                // header\r
-               List<RefModel> tags = JGitUtils.getTags(r, maxCount);\r
+               List<RefModel> tags = JGitUtils.getTags(r, false, maxCount);\r
                if (maxCount > 0) {\r
                        // summary page\r
                        // show tags page link\r
index 7196afdf1131621ae12b72dee156d4e13d5c5717..6646bf807a70167aefdb38cb865c63a5f8a5c08a 100644 (file)
@@ -139,7 +139,7 @@ public class JGitUtilsTest extends TestCase {
 \r
        public void testBranches() throws Exception {\r
                Repository repository = GitBlitSuite.getTicgitRepository();\r
-               for (RefModel model : JGitUtils.getLocalBranches(repository, -1)) {\r
+               for (RefModel model : JGitUtils.getLocalBranches(repository, true, -1)) {\r
                        assertTrue(model.getName().startsWith(Constants.R_HEADS));\r
                        assertTrue(model.equals(model));\r
                        assertFalse(model.equals(""));\r
@@ -147,7 +147,7 @@ public class JGitUtilsTest extends TestCase {
                                        + model.getName().hashCode());\r
                        assertTrue(model.getShortMessage().equals(model.getShortMessage()));\r
                }\r
-               for (RefModel model : JGitUtils.getRemoteBranches(repository, -1)) {\r
+               for (RefModel model : JGitUtils.getRemoteBranches(repository, true, -1)) {\r
                        assertTrue(model.getName().startsWith(Constants.R_REMOTES));\r
                        assertTrue(model.equals(model));\r
                        assertFalse(model.equals(""));\r
@@ -155,13 +155,13 @@ public class JGitUtilsTest extends TestCase {
                                        + model.getName().hashCode());\r
                        assertTrue(model.getShortMessage().equals(model.getShortMessage()));\r
                }\r
-               assertTrue(JGitUtils.getRemoteBranches(repository, 10).size() == 10);\r
+               assertTrue(JGitUtils.getRemoteBranches(repository, true, 10).size() == 10);\r
                repository.close();\r
        }\r
 \r
        public void testTags() throws Exception {\r
                Repository repository = GitBlitSuite.getTicgitRepository();\r
-               for (RefModel model : JGitUtils.getTags(repository, -1)) {\r
+               for (RefModel model : JGitUtils.getTags(repository, true, -1)) {\r
                        if (model.getObjectId().getName().equals("283035e4848054ff1803cb0e690270787dc92399")) {\r
                                assertTrue("Not an annotated tag!", model.isAnnotatedTag());\r
                        }\r
@@ -174,7 +174,7 @@ public class JGitUtilsTest extends TestCase {
                repository.close();\r
                \r
                repository = GitBlitSuite.getBluezGnomeRepository();\r
-               for (RefModel model : JGitUtils.getTags(repository, -1)) {\r
+               for (RefModel model : JGitUtils.getTags(repository, true, -1)) {\r
                        if (model.getObjectId().getName().equals("728643ec0c438c77e182898c2f2967dbfdc231c8")) {\r
                                assertFalse(model.isAnnotatedTag());\r
                                assertTrue(model.getAuthorIdent().getEmailAddress().equals("marcel@holtmann.org"));\r