## 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
}\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
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
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
\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
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
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
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
\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
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
\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
\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
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
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
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
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
\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
+ 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
+ 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
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